NOTES FROM SF:
FOR STEAMBOAT, COMPARE THE DETRENDED CLIAMTE NORMAL CURVES AGAINST EACH OTHER
Derry & fassnacht 2010 Compare climatology of SNOTEL stations= they don’t have the same climatol9ogy based on the snow data
Figure 5b - https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2009WR007835
This work is very preliminary as I get back into the coding swing of things. Data wrangling and figure generation will be done via R, but the rest of the project will be done using good ol’ microsoft products. This is just an entry point into data crunching and should by no means be considered a final product.
Also, I’m not great at this but whatever. I could automate this, but I’ll figure that out shortly!
Need to update figures & analyze sites for seasonal trends
SNOTEL data was provided by the NRCS. Data was cleaned by removing outliers that are likely implausible; any year with more than 15 observations missing was removed. Temperatures were adjusted using the Morrisey method for stations identified by Ma et al (2019) due to SNOTEL temperature sensor changes, with the adjustment applied to pre-sensor change data. Daily mean observations were detrended to determine whether values were increasing or decreasing from the entire time series trend. Daily mean temperatures were first averaged by water year, with all water year means then averaged by day of water year. The mean temperature by day for the period of record was averaged. To find the standard deviation, the daily mean temperatures by water year was subtracted from the averaged mean temperature by day for the period of record. All water year means averaged by day of water year were subtracted from the temperature mean. The resulting values were then added together to find the “residual” of the daily mean temperatures by water year. The standard deviation was then computed from those residuals, with trends analyzed by Mann‐Kendall significance test and Theil‐Sen’s rate of change. Significant trends are identified with p-values of less than 0.10.
Morrisey Method
The Morrisey Method is taken from Ma, Fassnacht and Kampf..
In R script: T(adjusted) = 5.3x10(-7)xT(old)4+3.72x10(-5)xT(old)3-2.16x10(-3)xT(old)2-7.32x10^(-2)xT(old)+1.37
In the Ma et al. spreadsheet, H1 is Morrisey, H2 is Oiler
Analyzing by summer and winter seasons for each station’s timeseries, using the shifted mean of the time series, then sigmoidal detrending. Standard deviation is taken with the relevant days of the water year.
Analyzing for spring and fall….
Yampa Area SNOTEL sites:
Burro Mountain 378 NSCE- Original, Bias- Morrisey 7/11/2002 (NSCE- 0.87 vs 0.84, Bias- -0.03 vs. 0.11)
Columbine 408 Morrisey 7/22/2005
Columbine Pass 409 Morrisey 6/23/2005
Crosho 426 Morrisey 7/21/2005
Dry Lake 457 Oyler -> Morrisey 7/30/2003
Elk River 467 Oyler -> Morrisey 8/7/2006
Lynx Pass 607 Morrisey 5/22/2006
Rabbit Ears 709 Morrisey 8/7/2006 (Does not go.)
Ripple Creek 717 Oyler -> Morrisey 8/7/2006
Tower 825 Original 8/18/2004
Trapper Lake 827 Original 12/13/2004
SNOTEL_yampa_area <- snotel_download(site_id = c(378, 408, 409, 426, 457, 467, 607, 709, 717, 825, 827), path = tempdir('../data'), internal = TRUE)
write.csv(SNOTEL_yampa_area,"C:/Users/13074/Documents/ESS580/thesis_project/Yampa/data_raw/snotel_yampa.csv", row.names = FALSE) #write in the raw data
SNOTEL_yampa_area <- read.csv("C:/Users/13074/Documents/ESS580/thesis_project/Yampa/data_raw/snotel_yampa.csv", header = TRUE)
NSCE- Original, Bias- Morrisey 7/11/2002 so, ORIGINAL. Morrisey is marked as having the smallest bias, but the sheet says original is smaller.
snotel_378 <- SNOTEL_yampa_area %>%
filter(site_id == "378")
#str(snotel_378) # check the date, usually a character.
snotel_378$Date <- as.Date(snotel_378$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_378_clean <- snotel_378 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_378_clean <- snotel_378_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_378_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_378_clean <- snotel_378_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40)# %>%
#filter(temperature_mean < 25)
ggplot(snotel_378_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_378_cull_count <- snotel_378_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_378_cull_count
# filtering for too few observations in a year
snotel_378_cull_count_days <- snotel_378_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_378_cull_count_days
## # A tibble: 10 x 2
## # Groups: waterYear [10]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1988 298
## 3 1989 341
## 4 1993 281
## 5 1994 261
## 6 1995 344
## 7 1996 320
## 8 2002 312
## 9 2016 310
## 10 2022 338
snotel_378_clean_culled <- snotel_378_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1988" & waterYear != "1989" & waterYear != "1993" & waterYear != "1994" & waterYear != "1995" & waterYear != "1996" & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_378_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Culling WY 1986 as well.
ggplot(snotel_378_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_378_xts <- xts(snotel_378_clean_culled$temperature_mean, order.by = snotel_378_clean_culled$Date)
dygraph(temp_378_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_378_clean_culled <- snotel_378_clean_culled %>%
# filter(temperature_mean < 19.3)
temp_378_xts <- xts(snotel_378_clean_culled$temperature_mean, order.by = snotel_378_clean_culled$Date)
dygraph(temp_378_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
NSCE- Original, Bias- Morrisey 7/11/2002
snotel_378_adjusted <- snotel_378_clean_culled %>%
mutate(temp_ad = if_else(Date < "2002-07-11", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_378 <- snotel_378_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_378 <- yearly_wy_aver_378 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_378 <- daily_wy_aver_378 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_378$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_378 <-daily_wy_aver_378 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_378$date_temp <- signif(daily_wy_aver2_378$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_378, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_378 <- daily_wy_aver_378 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_378 <- standard_dev_378 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_378 <- standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.562568 |
| 1990 | 9.114355 |
| 1991 | 9.254156 |
| 1992 | 8.275786 |
| 1997 | 8.898932 |
| 1998 | 8.983050 |
| 1999 | 8.073327 |
| 2000 | 8.686540 |
| 2001 | 9.301471 |
| 2003 | 8.509538 |
| 2004 | 8.017044 |
| 2005 | 7.723002 |
| 2006 | 8.547829 |
| 2007 | 8.796189 |
| 2008 | 8.749038 |
| 2009 | 7.771973 |
| 2010 | 8.617066 |
| 2011 | 8.282002 |
| 2012 | 8.445614 |
| 2013 | 8.991985 |
| 2014 | 8.166025 |
| 2015 | 7.657629 |
| 2017 | 8.034586 |
| 2018 | 8.020621 |
| 2019 | 8.518154 |
| 2020 | 8.848254 |
| 2021 | 8.718771 |
ggplot(standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average temperatures for water years 2005-2021
sd_mk_378 <- mk.test(standard_dev_all_378$sd_2)
print(sd_mk_378)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_378$sd_2
## z = -1.5427, n = 27, p-value = 0.1229
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -75.0000000 2301.0000000 -0.2136752
sd_sens_378 <- sens.slope(standard_dev_all_378$sd_2)
print(sd_sens_378)
##
## Sen's slope
##
## data: standard_dev_all_378$sd_2
## z = -1.5427, n = 27, p-value = 0.1229
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.047456119 0.006621254
## sample estimates:
## Sen's slope
## -0.0230883
#using the clean culled df:
#average water year temperature
yearly_wy_aver_378_ad <- snotel_378_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_378_ad <- yearly_wy_aver_378_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_378_ad <- daily_wy_aver_378_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_378_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_378_ad <-daily_wy_aver_378_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_378_ad$date_temp_ad <- signif(daily_wy_aver2_378_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_378_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_378_ad <- daily_wy_aver_378_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_378_ad <- standard_dev_378_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_378_ad <- standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 7.940547 |
| 1990 | 8.436056 |
| 1991 | 8.633602 |
| 1992 | 7.670874 |
| 1997 | 8.260208 |
| 1998 | 8.299486 |
| 1999 | 7.471734 |
| 2000 | 7.993287 |
| 2001 | 8.584377 |
| 2003 | 8.508522 |
| 2004 | 8.016141 |
| 2005 | 7.722598 |
| 2006 | 8.547499 |
| 2007 | 8.795362 |
| 2008 | 8.748133 |
| 2009 | 7.771479 |
| 2010 | 8.616338 |
| 2011 | 8.281602 |
| 2012 | 8.444783 |
| 2013 | 8.991116 |
| 2014 | 8.165236 |
| 2015 | 7.657576 |
| 2017 | 8.034186 |
| 2018 | 8.019986 |
| 2019 | 8.517552 |
| 2020 | 8.847387 |
| 2021 | 8.717958 |
ggplot(standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average temperatures for water years 1986-2021
sd_mk_378_ad <- mk.test(standard_dev_all_378_ad$sd_2)
print(sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_378_ad$sd_2
## z = 1.3342, n = 27, p-value = 0.1821
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 65.0000000 2301.0000000 0.1851852
sd_sens_378_ad <- sens.slope(standard_dev_all_378_ad$sd_2)
print(sd_sens_378_ad)
##
## Sen's slope
##
## data: standard_dev_all_378_ad$sd_2
## z = 1.3342, n = 27, p-value = 0.1821
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.009653315 0.035911433
## sample estimates:
## Sen's slope
## 0.01222034
summer_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_378 <- summer_standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.692116 |
| 1990 | 3.218920 |
| 1991 | 2.651801 |
| 1992 | 3.322142 |
| 1997 | 2.620765 |
| 1998 | 4.162893 |
| 1999 | 2.863029 |
| 2000 | 2.908442 |
| 2001 | 3.219714 |
| 2003 | 3.543937 |
| 2004 | 2.877612 |
| 2005 | 3.855347 |
| 2006 | 2.562891 |
| 2007 | 2.929393 |
| 2008 | 3.294480 |
| 2009 | 2.864196 |
| 2010 | 2.665386 |
| 2011 | 2.596359 |
| 2012 | 2.322815 |
| 2013 | 2.210477 |
| 2014 | 2.789473 |
| 2015 | 2.482188 |
| 2017 | 2.139191 |
| 2018 | 2.322244 |
| 2019 | 3.322417 |
| 2020 | 3.051559 |
| 2021 | 2.560482 |
ggplot(summer_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average summer temperatures for water years 2005-2021
summer_sd_mk_378 <- mk.test(summer_standard_dev_all_378$sd_2)
print(summer_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_378$sd_2
## z = -2.0847, n = 27, p-value = 0.0371
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -101.0000000 2301.0000000 -0.2877493
summer_sd_sens_378 <- sens.slope(summer_standard_dev_all_378$sd_2)
print(summer_sd_sens_378)
##
## Sen's slope
##
## data: summer_standard_dev_all_378$sd_2
## z = -2.0847, n = 27, p-value = 0.0371
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04999492 -0.00167060
## sample estimates:
## Sen's slope
## -0.02424276
Winter
winter_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_378 <- winter_standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.731640 |
| 1990 | 5.140343 |
| 1991 | 5.695027 |
| 1992 | 4.335750 |
| 1997 | 5.444861 |
| 1998 | 4.527625 |
| 1999 | 5.272255 |
| 2000 | 5.033986 |
| 2001 | 4.191216 |
| 2003 | 4.526174 |
| 2004 | 5.336220 |
| 2005 | 4.010536 |
| 2006 | 5.249817 |
| 2007 | 5.816186 |
| 2008 | 5.552880 |
| 2009 | 4.844035 |
| 2010 | 4.997813 |
| 2011 | 5.322224 |
| 2012 | 4.749572 |
| 2013 | 5.861543 |
| 2014 | 4.604877 |
| 2015 | 5.075992 |
| 2017 | 5.814147 |
| 2018 | 4.478841 |
| 2019 | 4.357042 |
| 2020 | 4.798305 |
| 2021 | 4.612667 |
ggplot(winter_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average winter temperatures for water years 2005-2021
winter_sd_mk_378 <- mk.test(winter_standard_dev_all_378$sd_2)
print(winter_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_378$sd_2
## z = -0.33355, n = 27, p-value = 0.7387
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -17.00000000 2301.00000000 -0.04843305
winter_sd_sens_378 <- sens.slope(winter_standard_dev_all_378$sd_2)
print(winter_sd_sens_378)
##
## Sen's slope
##
## data: winter_standard_dev_all_378$sd_2
## z = -0.33355, n = 27, p-value = 0.7387
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03898791 0.02758813
## sample estimates:
## Sen's slope
## -0.004573031
Summer
summer_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_378_ad <- summer_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.413468 |
| 1990 | 2.889887 |
| 1991 | 2.380914 |
| 1992 | 2.982435 |
| 1997 | 2.347914 |
| 1998 | 3.745285 |
| 1999 | 2.568318 |
| 2000 | 2.604670 |
| 2001 | 2.892967 |
| 2003 | 3.544511 |
| 2004 | 2.877645 |
| 2005 | 3.856184 |
| 2006 | 2.563720 |
| 2007 | 2.929659 |
| 2008 | 3.294462 |
| 2009 | 2.864766 |
| 2010 | 2.665624 |
| 2011 | 2.596824 |
| 2012 | 2.322400 |
| 2013 | 2.211029 |
| 2014 | 2.790029 |
| 2015 | 2.481841 |
| 2017 | 2.139606 |
| 2018 | 2.322187 |
| 2019 | 3.322841 |
| 2020 | 3.051212 |
| 2021 | 2.561033 |
ggplot(summer_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average summer temperatures for water years 1986-2021
summer_sd_mk_378_ad <- mk.test(summer_standard_dev_all_378_ad$sd_2)
print(summer_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_378_ad$sd_2
## z = -0.95896, n = 27, p-value = 0.3376
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -47.0000000 2301.0000000 -0.1339031
summer_sd_sens_378_ad <- sens.slope(summer_standard_dev_all_378_ad$sd_2)
print(summer_sd_sens_378_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_378_ad$sd_2
## z = -0.95896, n = 27, p-value = 0.3376
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03162510 0.01583649
## sample estimates:
## Sen's slope
## -0.00876158
Winter
winter_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_378_ad <- winter_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.549129 |
| 1990 | 4.931690 |
| 1991 | 5.556790 |
| 1992 | 4.168096 |
| 1997 | 5.226297 |
| 1998 | 4.336519 |
| 1999 | 5.039384 |
| 2000 | 4.780285 |
| 2001 | 4.032956 |
| 2003 | 4.524147 |
| 2004 | 5.335113 |
| 2005 | 4.010037 |
| 2006 | 5.249889 |
| 2007 | 5.815371 |
| 2008 | 5.551480 |
| 2009 | 4.843795 |
| 2010 | 4.996600 |
| 2011 | 5.321782 |
| 2012 | 4.748165 |
| 2013 | 5.860984 |
| 2014 | 4.603416 |
| 2015 | 5.076952 |
| 2017 | 5.814240 |
| 2018 | 4.478524 |
| 2019 | 4.356389 |
| 2020 | 4.796933 |
| 2021 | 4.611592 |
ggplot(winter_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average winter temperatures for water years 1986-2021
winter_sd_mk_378_ad <- mk.test(winter_standard_dev_all_378_ad$sd_2)
print(winter_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_378_ad$sd_2
## z = 0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.300000e+01 2.301000e+03 3.703704e-02
winter_sd_sens_378_ad <- sens.slope(winter_standard_dev_all_378_ad$sd_2)
print(winter_sd_sens_378_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_378_ad$sd_2
## z = 0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02770969 0.03870334
## sample estimates:
## Sen's slope
## 0.00294903
spring_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_378 <- spring_standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.340999 |
| 1990 | 3.791608 |
| 1991 | 5.559594 |
| 1992 | 3.340770 |
| 1997 | 5.778697 |
| 1998 | 4.763830 |
| 1999 | 5.187829 |
| 2000 | 5.315978 |
| 2001 | 4.638695 |
| 2003 | 5.017735 |
| 2004 | 3.958875 |
| 2005 | 4.194216 |
| 2006 | 3.912872 |
| 2007 | 4.370620 |
| 2008 | 4.837903 |
| 2009 | 4.663164 |
| 2010 | 4.790609 |
| 2011 | 4.096486 |
| 2012 | 4.004034 |
| 2013 | 5.443048 |
| 2014 | 5.093807 |
| 2015 | 2.975427 |
| 2017 | 4.386292 |
| 2018 | 4.720389 |
| 2019 | 3.425139 |
| 2020 | 5.023624 |
| 2021 | 4.391769 |
ggplot(spring_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average spring temperatures for water years 2005-2021
spring_sd_mk_378 <- mk.test(spring_standard_dev_all_378$sd_2)
print(spring_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_378$sd_2
## z = -0.54202, n = 27, p-value = 0.5878
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -27.00000000 2301.00000000 -0.07692308
spring_sd_sens_378 <- sens.slope(spring_standard_dev_all_378$sd_2)
print(spring_sd_sens_378)
##
## Sen's slope
##
## data: spring_standard_dev_all_378$sd_2
## z = -0.54202, n = 27, p-value = 0.5878
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05829606 0.02705585
## sample estimates:
## Sen's slope
## -0.0162883
Fall
fall_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_378 <- fall_standard_dev_all_378 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.431606 |
| 1990 | 6.145594 |
| 1991 | 4.656173 |
| 1992 | 5.847224 |
| 1997 | 6.136725 |
| 1998 | 6.254336 |
| 1999 | 4.045670 |
| 2000 | 5.039120 |
| 2001 | 5.009131 |
| 2003 | 4.303230 |
| 2004 | 3.906389 |
| 2005 | 4.526478 |
| 2006 | 4.098161 |
| 2007 | 5.606051 |
| 2008 | 4.065270 |
| 2009 | 4.652840 |
| 2010 | 6.033833 |
| 2011 | 4.233049 |
| 2012 | 5.016351 |
| 2013 | 5.171255 |
| 2014 | 5.435845 |
| 2015 | 3.843870 |
| 2017 | 4.214933 |
| 2018 | 5.203989 |
| 2019 | 5.572001 |
| 2020 | 7.714938 |
| 2021 | 5.668374 |
ggplot(fall_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_378 <- mk.test(fall_standard_dev_all_378$sd_2)
print(fall_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_378$sd_2
## z = 0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.300000e+01 2.301000e+03 3.703704e-02
fall_sd_sens_378 <- sens.slope(fall_standard_dev_all_378$sd_2)
print(fall_sd_sens_378)
##
## Sen's slope
##
## data: fall_standard_dev_all_378$sd_2
## z = 0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03828000 0.07101703
## sample estimates:
## Sen's slope
## 0.01030432
Spring
spring_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_378_ad <- spring_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.989266 |
| 1990 | 3.469032 |
| 1991 | 5.132326 |
| 1992 | 3.043576 |
| 1997 | 5.377129 |
| 1998 | 4.361311 |
| 1999 | 4.793832 |
| 2000 | 4.844663 |
| 2001 | 4.246176 |
| 2003 | 5.018380 |
| 2004 | 3.958109 |
| 2005 | 4.193790 |
| 2006 | 3.912897 |
| 2007 | 4.368799 |
| 2008 | 4.836130 |
| 2009 | 4.661775 |
| 2010 | 4.790192 |
| 2011 | 4.095602 |
| 2012 | 4.003310 |
| 2013 | 5.441030 |
| 2014 | 5.093242 |
| 2015 | 2.974379 |
| 2017 | 4.386387 |
| 2018 | 4.718164 |
| 2019 | 3.423520 |
| 2020 | 5.021675 |
| 2021 | 4.390585 |
ggplot(spring_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average spring temperatures for water years 1986-2021
spring_sd_mk_378_ad <- mk.test(spring_standard_dev_all_378_ad$sd_2)
print(spring_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_378_ad$sd_2
## z = 0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.300000e+01 2.301000e+03 3.703704e-02
spring_sd_sens_378_ad <- sens.slope(spring_standard_dev_all_378_ad$sd_2)
print(spring_sd_sens_378_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_378_ad$sd_2
## z = 0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03259833 0.04368361
## sample estimates:
## Sen's slope
## 0.001675836
Fall
fall_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_378_ad <- fall_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.060032 |
| 1990 | 5.622125 |
| 1991 | 4.255387 |
| 1992 | 5.435000 |
| 1997 | 5.651351 |
| 1998 | 5.718878 |
| 1999 | 3.700177 |
| 2000 | 4.589813 |
| 2001 | 4.536935 |
| 2003 | 4.303298 |
| 2004 | 3.904954 |
| 2005 | 4.526816 |
| 2006 | 4.098928 |
| 2007 | 5.606273 |
| 2008 | 4.066523 |
| 2009 | 4.653499 |
| 2010 | 6.034106 |
| 2011 | 4.234057 |
| 2012 | 5.017135 |
| 2013 | 5.170178 |
| 2014 | 5.435919 |
| 2015 | 3.846517 |
| 2017 | 4.214034 |
| 2018 | 5.204662 |
| 2019 | 5.572770 |
| 2020 | 7.716071 |
| 2021 | 5.667700 |
ggplot(fall_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_378_ad <- mk.test(fall_standard_dev_all_378_ad$sd_2)
print(fall_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_378_ad$sd_2
## z = 1.2091, n = 27, p-value = 0.2266
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 59.0000000 2301.0000000 0.1680912
fall_sd_sens_378_ad <- sens.slope(fall_standard_dev_all_378_ad$sd_2)
print(fall_sd_sens_378_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_378_ad$sd_2
## z = 1.2091, n = 27, p-value = 0.2266
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01407560 0.07491534
## sample estimates:
## Sen's slope
## 0.03211602
Morrisey 7/22/2005
snotel_408 <- SNOTEL_yampa_area %>%
filter(site_id == "408")
#str(snotel_408) # check the date, usually a character.
snotel_408$Date <- as.Date(snotel_408$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_408_clean <- snotel_408 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_408_clean <- snotel_408_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_408_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_408_clean <- snotel_408_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40)# %>%
#filter(temperature_mean < 25)
ggplot(snotel_408_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_408_cull_count <- snotel_408_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_408_cull_count
# filtering for too few observations in a year
snotel_408_cull_count_days <- snotel_408_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_408_cull_count_days
## # A tibble: 8 x 2
## # Groups: waterYear [8]
## waterYear n
## <dbl> <int>
## 1 1981 343
## 2 1983 317
## 3 1984 234
## 4 1985 195
## 5 1986 336
## 6 1987 298
## 7 1994 272
## 8 2002 347
snotel_408_clean_culled <- snotel_408_clean %>%
filter(waterYear > "1987" & waterYear != "1993" & waterYear != "1994" & waterYear != "2002")# & waterYear != "1985" & waterYear != "1986" & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_408_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Culling WY 1986 & 1993 as well.
ggplot(snotel_408_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_408_xts <- xts(snotel_408_clean_culled$temperature_mean, order.by = snotel_408_clean_culled$Date)
dygraph(temp_408_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
snotel_408_clean_culled <- snotel_408_clean_culled %>%
filter(temperature_mean > -30)
temp_408_xts <- xts(snotel_408_clean_culled$temperature_mean, order.by = snotel_408_clean_culled$Date)
dygraph(temp_408_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
snotel_408_adjusted <- snotel_408_clean_culled %>%
mutate(temp_ad = if_else(Date < "2005-07-22", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_408 <- snotel_408_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_408 <- yearly_wy_aver_408 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_408 <- daily_wy_aver_408 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_408$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_408 <-daily_wy_aver_408 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_408$date_temp <- signif(daily_wy_aver2_408$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_408, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_408 <- daily_wy_aver_408 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_408 <- standard_dev_408 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_408 <- standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 9.911311 |
| 1989 | 9.479817 |
| 1990 | 8.845588 |
| 1991 | 9.141713 |
| 1992 | 8.235717 |
| 1995 | 8.387811 |
| 1996 | 8.807923 |
| 1997 | 8.867338 |
| 1998 | 9.074387 |
| 1999 | 8.232888 |
| 2000 | 8.585091 |
| 2001 | 9.380546 |
| 2003 | 8.847298 |
| 2004 | 8.495495 |
| 2005 | 8.135796 |
| 2006 | 8.734304 |
| 2007 | 8.839901 |
| 2008 | 8.888992 |
| 2009 | 7.926154 |
| 2010 | 8.738675 |
| 2011 | 8.455577 |
| 2012 | 8.702054 |
| 2013 | 9.110505 |
| 2014 | 8.268271 |
| 2015 | 7.870630 |
| 2016 | 8.492743 |
| 2017 | 8.238399 |
| 2018 | 8.140089 |
| 2019 | 8.644103 |
| 2020 | 9.027143 |
| 2021 | 8.902353 |
| 2022 | 8.706784 |
ggplot(standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average temperatures for water years 2005-2021
sd_mk_408 <- mk.test(standard_dev_all_408$sd_2)
print(sd_mk_408)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_408$sd_2
## z = -1.7676, n = 32, p-value = 0.07713
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -110.0000000 3802.6666667 -0.2217742
sd_sens_408 <- sens.slope(standard_dev_all_408$sd_2)
print(sd_sens_408)
##
## Sen's slope
##
## data: standard_dev_all_408$sd_2
## z = -1.7676, n = 32, p-value = 0.07713
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.033742130 0.001027723
## sample estimates:
## Sen's slope
## -0.01615257
#using the clean culled df:
#average water year temperature
yearly_wy_aver_408_ad <- snotel_408_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_408_ad <- yearly_wy_aver_408_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_408_ad <- daily_wy_aver_408_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_408_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_408_ad <-daily_wy_aver_408_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_408_ad$date_temp_ad <- signif(daily_wy_aver2_408_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_408_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_408_ad <- daily_wy_aver_408_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_408_ad <- standard_dev_408_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_408_ad <- standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 9.255004 |
| 1989 | 8.873391 |
| 1990 | 8.216764 |
| 1991 | 8.545580 |
| 1992 | 7.664569 |
| 1995 | 7.780528 |
| 1996 | 8.186934 |
| 1997 | 8.260524 |
| 1998 | 8.410419 |
| 1999 | 7.651225 |
| 2000 | 7.928801 |
| 2001 | 8.691699 |
| 2003 | 8.174582 |
| 2004 | 7.895518 |
| 2005 | 7.482674 |
| 2006 | 8.735962 |
| 2007 | 8.841502 |
| 2008 | 8.890875 |
| 2009 | 7.928502 |
| 2010 | 8.741101 |
| 2011 | 8.457260 |
| 2012 | 8.703940 |
| 2013 | 9.112301 |
| 2014 | 8.270874 |
| 2015 | 7.872234 |
| 2016 | 8.495258 |
| 2017 | 8.239886 |
| 2018 | 8.142322 |
| 2019 | 8.646452 |
| 2020 | 9.028953 |
| 2021 | 8.904182 |
| 2022 | 8.708980 |
ggplot(standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average temperatures for water years 1986-2021
sd_mk_408_ad <- mk.test(standard_dev_all_408_ad$sd_2)
print(sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_408_ad$sd_2
## z = 1.2487, n = 32, p-value = 0.2118
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 78.0000000 3802.6666667 0.1572581
sd_sens_408_ad <- sens.slope(standard_dev_all_408_ad$sd_2)
print(sd_sens_408_ad)
##
## Sen's slope
##
## data: standard_dev_all_408_ad$sd_2
## z = 1.2487, n = 32, p-value = 0.2118
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.007349474 0.033195852
## sample estimates:
## Sen's slope
## 0.01316118
summer_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_408 <- summer_standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 2.504373 |
| 1989 | 3.699022 |
| 1990 | 2.926784 |
| 1991 | 2.619124 |
| 1992 | 2.998010 |
| 1995 | 3.637168 |
| 1996 | 2.391688 |
| 1997 | 2.424907 |
| 1998 | 3.921981 |
| 1999 | 2.637264 |
| 2000 | 2.729286 |
| 2001 | 3.221677 |
| 2003 | 3.777047 |
| 2004 | 3.046434 |
| 2005 | 3.599270 |
| 2006 | 2.513246 |
| 2007 | 2.952934 |
| 2008 | 3.362967 |
| 2009 | 2.921177 |
| 2010 | 2.593838 |
| 2011 | 2.512283 |
| 2012 | 2.218537 |
| 2013 | 2.213130 |
| 2014 | 2.561540 |
| 2015 | 2.061628 |
| 2016 | 2.174975 |
| 2017 | 2.056479 |
| 2018 | 2.418481 |
| 2019 | 3.113983 |
| 2020 | 2.700271 |
| 2021 | 2.592532 |
| 2022 | 2.540400 |
ggplot(summer_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average summer temperatures for water years 2005-2021
summer_sd_mk_408 <- mk.test(summer_standard_dev_all_408$sd_2)
print(summer_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_408$sd_2
## z = -2.3514, n = 32, p-value = 0.0187
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -146.0000000 3802.6666667 -0.2943548
summer_sd_sens_408 <- sens.slope(summer_standard_dev_all_408$sd_2)
print(summer_sd_sens_408)
##
## Sen's slope
##
## data: summer_standard_dev_all_408$sd_2
## z = -2.3514, n = 32, p-value = 0.0187
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.043207876 -0.003181174
## sample estimates:
## Sen's slope
## -0.02165166
Winter
winter_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_408 <- winter_standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 5.448539 |
| 1989 | 5.958291 |
| 1990 | 4.883971 |
| 1991 | 5.465249 |
| 1992 | 4.220851 |
| 1995 | 5.072519 |
| 1996 | 5.122992 |
| 1997 | 5.313409 |
| 1998 | 4.454019 |
| 1999 | 5.188060 |
| 2000 | 4.787195 |
| 2001 | 4.093398 |
| 2003 | 4.244064 |
| 2004 | 5.273843 |
| 2005 | 4.378660 |
| 2006 | 5.168996 |
| 2007 | 5.619239 |
| 2008 | 5.298824 |
| 2009 | 4.886368 |
| 2010 | 5.067445 |
| 2011 | 5.246893 |
| 2012 | 4.843984 |
| 2013 | 5.661977 |
| 2014 | 4.658046 |
| 2015 | 5.463103 |
| 2016 | 4.778758 |
| 2017 | 6.095123 |
| 2018 | 4.507022 |
| 2019 | 4.275037 |
| 2020 | 4.710772 |
| 2021 | 4.483947 |
| 2022 | 5.416435 |
ggplot(winter_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average winter temperatures for water years 2005-2021
winter_sd_mk_408 <- mk.test(winter_standard_dev_all_408$sd_2)
print(winter_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_408$sd_2
## z = -0.63244, n = 32, p-value = 0.5271
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -40.00000000 3802.66666667 -0.08064516
winter_sd_sens_408 <- sens.slope(winter_standard_dev_all_408$sd_2)
print(winter_sd_sens_408)
##
## Sen's slope
##
## data: winter_standard_dev_all_408$sd_2
## z = -0.63244, n = 32, p-value = 0.5271
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02894210 0.01541287
## sample estimates:
## Sen's slope
## -0.009441808
Summer
summer_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_408_ad <- summer_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 2.249329 |
| 1989 | 3.324335 |
| 1990 | 2.627145 |
| 1991 | 2.350771 |
| 1992 | 2.696372 |
| 1995 | 3.267930 |
| 1996 | 2.145360 |
| 1997 | 2.173724 |
| 1998 | 3.529518 |
| 1999 | 2.367246 |
| 2000 | 2.444964 |
| 2001 | 2.898106 |
| 2003 | 3.387539 |
| 2004 | 2.734124 |
| 2005 | 3.255474 |
| 2006 | 2.515439 |
| 2007 | 2.953824 |
| 2008 | 3.363488 |
| 2009 | 2.921758 |
| 2010 | 2.594185 |
| 2011 | 2.513053 |
| 2012 | 2.218518 |
| 2013 | 2.215107 |
| 2014 | 2.564239 |
| 2015 | 2.059421 |
| 2016 | 2.175303 |
| 2017 | 2.057888 |
| 2018 | 2.421159 |
| 2019 | 3.115442 |
| 2020 | 2.701103 |
| 2021 | 2.595007 |
| 2022 | 2.541932 |
ggplot(summer_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average summer temperatures for water years 1986-2021
summer_sd_mk_408_ad <- mk.test(summer_standard_dev_all_408_ad$sd_2)
print(summer_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_408_ad$sd_2
## z = -0.95677, n = 32, p-value = 0.3387
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -60.0000000 3802.6666667 -0.1209677
summer_sd_sens_408_ad <- sens.slope(summer_standard_dev_all_408_ad$sd_2)
print(summer_sd_sens_408_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_408_ad$sd_2
## z = -0.95677, n = 32, p-value = 0.3387
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.026916898 0.009175002
## sample estimates:
## Sen's slope
## -0.00742486
Winter
winter_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_408_ad <- winter_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 5.307398 |
| 1989 | 5.797219 |
| 1990 | 4.711924 |
| 1991 | 5.354050 |
| 1992 | 4.084042 |
| 1995 | 4.869678 |
| 1996 | 4.954861 |
| 1997 | 5.127867 |
| 1998 | 4.285759 |
| 1999 | 5.001769 |
| 2000 | 4.569089 |
| 2001 | 3.959096 |
| 2003 | 4.085307 |
| 2004 | 5.060019 |
| 2005 | 4.233391 |
| 2006 | 5.170831 |
| 2007 | 5.619124 |
| 2008 | 5.298153 |
| 2009 | 4.887542 |
| 2010 | 5.067893 |
| 2011 | 5.246217 |
| 2012 | 4.844042 |
| 2013 | 5.661765 |
| 2014 | 4.659840 |
| 2015 | 5.462227 |
| 2016 | 4.780285 |
| 2017 | 6.094801 |
| 2018 | 4.507227 |
| 2019 | 4.275086 |
| 2020 | 4.709599 |
| 2021 | 4.483696 |
| 2022 | 5.416482 |
ggplot(winter_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average winter temperatures for water years 1986-2021
winter_sd_mk_408_ad <- mk.test(winter_standard_dev_all_408_ad$sd_2)
print(winter_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_408_ad$sd_2
## z = 0, n = 32, p-value = 1
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 0.000 3802.667 0.000
winter_sd_sens_408_ad <- sens.slope(winter_standard_dev_all_408_ad$sd_2)
print(winter_sd_sens_408_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_408_ad$sd_2
## z = 0, n = 32, p-value = 1
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02184777 0.02493868
## sample estimates:
## Sen's slope
## 3.6027e-05
spring_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_408 <- spring_standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 5.091514 |
| 1989 | 4.946228 |
| 1990 | 3.578944 |
| 1991 | 5.136807 |
| 1992 | 3.602599 |
| 1995 | 3.436405 |
| 1996 | 4.685517 |
| 1997 | 5.679009 |
| 1998 | 4.543568 |
| 1999 | 5.360440 |
| 2000 | 5.186044 |
| 2001 | 4.529147 |
| 2003 | 5.373774 |
| 2004 | 4.276333 |
| 2005 | 4.233419 |
| 2006 | 3.966200 |
| 2007 | 4.305559 |
| 2008 | 5.037061 |
| 2009 | 4.725877 |
| 2010 | 4.736574 |
| 2011 | 4.043300 |
| 2012 | 4.002537 |
| 2013 | 5.583534 |
| 2014 | 5.120352 |
| 2015 | 3.087531 |
| 2016 | 3.926155 |
| 2017 | 4.232645 |
| 2018 | 4.521587 |
| 2019 | 3.440298 |
| 2020 | 5.056515 |
| 2021 | 4.454418 |
| 2022 | 4.881097 |
ggplot(spring_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average spring temperatures for water years 2005-2021
spring_sd_mk_408 <- mk.test(spring_standard_dev_all_408$sd_2)
print(spring_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_408$sd_2
## z = -0.8919, n = 32, p-value = 0.3724
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -56.0000000 3802.6666667 -0.1129032
spring_sd_sens_408 <- sens.slope(spring_standard_dev_all_408$sd_2)
print(spring_sd_sens_408)
##
## Sen's slope
##
## data: spring_standard_dev_all_408$sd_2
## z = -0.8919, n = 32, p-value = 0.3724
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04291385 0.01823091
## sample estimates:
## Sen's slope
## -0.01374157
Fall
fall_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_408 <- fall_standard_dev_all_408 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.579536 |
| 1989 | 3.646665 |
| 1990 | 6.066536 |
| 1991 | 4.799360 |
| 1992 | 6.714577 |
| 1995 | 5.307872 |
| 1996 | 5.344485 |
| 1997 | 6.335858 |
| 1998 | 6.344729 |
| 1999 | 3.947483 |
| 2000 | 4.952660 |
| 2001 | 4.715821 |
| 2003 | 4.714915 |
| 2004 | 3.972941 |
| 2005 | 4.748175 |
| 2006 | 3.841704 |
| 2007 | 5.520408 |
| 2008 | 3.964625 |
| 2009 | 4.622630 |
| 2010 | 6.110864 |
| 2011 | 4.445282 |
| 2012 | 5.084316 |
| 2013 | 5.056082 |
| 2014 | 5.459172 |
| 2015 | 3.897684 |
| 2016 | 3.963565 |
| 2017 | 4.396901 |
| 2018 | 5.429415 |
| 2019 | 5.597017 |
| 2020 | 7.856306 |
| 2021 | 5.517165 |
| 2022 | 5.533578 |
ggplot(fall_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_408 <- mk.test(fall_standard_dev_all_408$sd_2)
print(fall_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_408$sd_2
## z = 0.50271, n = 32, p-value = 0.6152
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.200000e+01 3.802667e+03 6.451613e-02
fall_sd_sens_408 <- sens.slope(fall_standard_dev_all_408$sd_2)
print(fall_sd_sens_408)
##
## Sen's slope
##
## data: fall_standard_dev_all_408$sd_2
## z = 0.50271, n = 32, p-value = 0.6152
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03342835 0.04459968
## sample estimates:
## Sen's slope
## 0.008512035
Spring
spring_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_408_ad <- spring_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.696123 |
| 1989 | 4.541737 |
| 1990 | 3.288275 |
| 1991 | 4.747017 |
| 1992 | 3.289816 |
| 1995 | 3.187341 |
| 1996 | 4.317672 |
| 1997 | 5.316551 |
| 1998 | 4.163483 |
| 1999 | 4.979522 |
| 2000 | 4.748269 |
| 2001 | 4.152728 |
| 2003 | 4.923677 |
| 2004 | 3.907812 |
| 2005 | 3.871285 |
| 2006 | 3.966091 |
| 2007 | 4.305243 |
| 2008 | 5.037224 |
| 2009 | 4.725733 |
| 2010 | 4.736820 |
| 2011 | 4.043738 |
| 2012 | 4.002759 |
| 2013 | 5.583738 |
| 2014 | 5.120794 |
| 2015 | 3.087539 |
| 2016 | 3.926615 |
| 2017 | 4.232698 |
| 2018 | 4.521574 |
| 2019 | 3.440682 |
| 2020 | 5.056464 |
| 2021 | 4.453756 |
| 2022 | 4.880974 |
ggplot(spring_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average spring temperatures for water years 1986-2021
spring_sd_mk_408_ad <- mk.test(spring_standard_dev_all_408_ad$sd_2)
print(spring_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_408_ad$sd_2
## z = 0.50271, n = 32, p-value = 0.6152
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.200000e+01 3.802667e+03 6.451613e-02
spring_sd_sens_408_ad <- sens.slope(spring_standard_dev_all_408_ad$sd_2)
print(spring_sd_sens_408_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_408_ad$sd_2
## z = 0.50271, n = 32, p-value = 0.6152
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02268431 0.03251101
## sample estimates:
## Sen's slope
## 0.00619877
Fall
fall_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_408_ad <- fall_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.174434 |
| 1989 | 3.305405 |
| 1990 | 5.555839 |
| 1991 | 4.399143 |
| 1992 | 6.290483 |
| 1995 | 4.836667 |
| 1996 | 4.899157 |
| 1997 | 5.854354 |
| 1998 | 5.810715 |
| 1999 | 3.616217 |
| 2000 | 4.529238 |
| 2001 | 4.287294 |
| 2003 | 4.325128 |
| 2004 | 3.615805 |
| 2005 | 4.202477 |
| 2006 | 3.845249 |
| 2007 | 5.528295 |
| 2008 | 3.972439 |
| 2009 | 4.631976 |
| 2010 | 6.121722 |
| 2011 | 4.452357 |
| 2012 | 5.092049 |
| 2013 | 5.062780 |
| 2014 | 5.467892 |
| 2015 | 3.906930 |
| 2016 | 3.970499 |
| 2017 | 4.401527 |
| 2018 | 5.438519 |
| 2019 | 5.606537 |
| 2020 | 7.863948 |
| 2021 | 5.522560 |
| 2022 | 5.542402 |
ggplot(fall_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_408_ad <- mk.test(fall_standard_dev_all_408_ad$sd_2)
print(fall_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_408_ad$sd_2
## z = 1.3135, n = 32, p-value = 0.189
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 82.0000000 3802.6666667 0.1653226
fall_sd_sens_408_ad <- sens.slope(fall_standard_dev_all_408_ad$sd_2)
print(fall_sd_sens_408_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_408_ad$sd_2
## z = 1.3135, n = 32, p-value = 0.189
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01125072 0.06406705
## sample estimates:
## Sen's slope
## 0.02757398
Morrisey 6/23/2005
snotel_409 <- SNOTEL_yampa_area %>%
filter(site_id == "409")
#str(snotel_409) # check the date, usually a character.
snotel_409$Date <- as.Date(snotel_409$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_409_clean <- snotel_409 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_409_clean <- snotel_409_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_409_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_409_clean <- snotel_409_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -50) %>%
filter(temperature_mean < 40)
ggplot(snotel_409_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_409_cull_count <- snotel_409_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_409_cull_count
# filtering for too few observations in a year
snotel_409_cull_count_days <- snotel_409_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_409_cull_count_days
## # A tibble: 5 x 2
## # Groups: waterYear [5]
## waterYear n
## <dbl> <int>
## 1 1994 331
## 2 1995 190
## 3 2005 329
## 4 2019 348
## 5 2022 346
snotel_409_clean_culled <- snotel_409_clean %>%
filter(waterYear != "1994" & waterYear != "1995" & waterYear != "2005" & waterYear != "2019" & waterYear != "2022")# & waterYear != "1986" & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_409_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_409_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_409_xts <- xts(snotel_409_clean_culled$temperature_mean, order.by = snotel_409_clean_culled$Date)
dygraph(temp_409_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_409_clean_culled <- snotel_409_clean_culled %>%
# filter(temperature_mean > -30)
#temp_409_xts <- xts(snotel_409_clean_culled$temperature_mean, order.by = snotel_409_clean_culled$Date)
#dygraph(temp_409_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
Morrisey 6/23/2005
snotel_409_adjusted <- snotel_409_clean_culled %>%
mutate(temp_ad = if_else(Date < "2005-06-23", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_409 <- snotel_409_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_409 <- yearly_wy_aver_409 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_409 <- daily_wy_aver_409 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_409$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_409 <-daily_wy_aver_409 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_409$date_temp <- signif(daily_wy_aver2_409$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_409, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_409 <- daily_wy_aver_409 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_409 <- standard_dev_409 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_409 <- standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.326403 |
| 1988 | 9.167257 |
| 1989 | 8.983106 |
| 1990 | 8.555010 |
| 1991 | 7.839925 |
| 1992 | 7.987351 |
| 1993 | 8.471182 |
| 1996 | 8.508682 |
| 1997 | 8.478813 |
| 1998 | 8.929006 |
| 1999 | 7.623863 |
| 2000 | 8.631812 |
| 2001 | 9.047367 |
| 2002 | 9.516272 |
| 2003 | 8.791318 |
| 2004 | 8.708583 |
| 2006 | 8.125432 |
| 2007 | 8.536611 |
| 2008 | 8.816576 |
| 2009 | 7.846243 |
| 2010 | 8.511418 |
| 2011 | 8.496243 |
| 2012 | 8.285134 |
| 2013 | 8.792304 |
| 2014 | 7.958185 |
| 2015 | 7.393468 |
| 2016 | 8.187794 |
| 2017 | 8.066498 |
| 2018 | 7.805356 |
| 2020 | 8.856536 |
| 2021 | 8.674169 |
ggplot(standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average temperatures for water years 2005-2021
sd_mk_409 <- mk.test(standard_dev_all_409$sd_2)
print(sd_mk_409)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_409$sd_2
## z = -1.1218, n = 31, p-value = 0.262
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -67.000000 3461.666667 -0.144086
sd_sens_409 <- sens.slope(standard_dev_all_409$sd_2)
print(sd_sens_409)
##
## Sen's slope
##
## data: standard_dev_all_409$sd_2
## z = -1.1218, n = 31, p-value = 0.262
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.034898600 0.009250748
## sample estimates:
## Sen's slope
## -0.01256069
#using the clean culled df:
#average water year temperature
yearly_wy_aver_409_ad <- snotel_409_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_409_ad <- yearly_wy_aver_409_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_409_ad <- daily_wy_aver_409_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_409_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_409_ad <-daily_wy_aver_409_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_409_ad$date_temp_ad <- signif(daily_wy_aver2_409_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_409_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_409_ad <- daily_wy_aver_409_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_409_ad <- standard_dev_409_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_409_ad <- standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 7.660579 |
| 1988 | 8.456632 |
| 1989 | 8.306699 |
| 1990 | 7.862004 |
| 1991 | 7.209890 |
| 1992 | 7.340956 |
| 1993 | 7.806529 |
| 1996 | 7.809598 |
| 1997 | 7.810012 |
| 1998 | 8.200421 |
| 1999 | 7.004624 |
| 2000 | 7.910753 |
| 2001 | 8.302261 |
| 2002 | 8.749019 |
| 2003 | 8.046898 |
| 2004 | 8.036896 |
| 2006 | 8.125530 |
| 2007 | 8.536428 |
| 2008 | 8.816453 |
| 2009 | 7.846083 |
| 2010 | 8.511060 |
| 2011 | 8.495994 |
| 2012 | 8.285156 |
| 2013 | 8.792015 |
| 2014 | 7.958138 |
| 2015 | 7.393110 |
| 2016 | 8.187413 |
| 2017 | 8.066215 |
| 2018 | 7.805282 |
| 2020 | 8.856204 |
| 2021 | 8.673923 |
ggplot(standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average temperatures for water years 1986-2021
sd_mk_409_ad <- mk.test(standard_dev_all_409_ad$sd_2)
print(sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_409_ad$sd_2
## z = 2.1415, n = 31, p-value = 0.03223
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 127.0000000 3461.6666667 0.2731183
sd_sens_409_ad <- sens.slope(standard_dev_all_409_ad$sd_2)
print(sd_sens_409_ad)
##
## Sen's slope
##
## data: standard_dev_all_409_ad$sd_2
## z = 2.1415, n = 31, p-value = 0.03223
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## 0.002607708 0.039439754
## sample estimates:
## Sen's slope
## 0.02152587
summer_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_409 <- summer_standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.672703 |
| 1988 | 2.748061 |
| 1989 | 3.396818 |
| 1990 | 3.105696 |
| 1991 | 2.832490 |
| 1992 | 3.170451 |
| 1993 | 3.429160 |
| 1996 | 2.363291 |
| 1997 | 2.548297 |
| 1998 | 3.749704 |
| 1999 | 2.849908 |
| 2000 | 2.607857 |
| 2001 | 3.052987 |
| 2002 | 2.907097 |
| 2003 | 3.326873 |
| 2004 | 2.737147 |
| 2006 | 2.422094 |
| 2007 | 2.486405 |
| 2008 | 2.894123 |
| 2009 | 3.016624 |
| 2010 | 2.633990 |
| 2011 | 2.339419 |
| 2012 | 2.097421 |
| 2013 | 2.264887 |
| 2014 | 2.575596 |
| 2015 | 2.599878 |
| 2016 | 2.616657 |
| 2017 | 1.982422 |
| 2018 | 2.042295 |
| 2020 | 2.972374 |
| 2021 | 2.789754 |
ggplot(summer_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average summer temperatures for water years 2005-2021
summer_sd_mk_409 <- mk.test(summer_standard_dev_all_409$sd_2)
print(summer_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_409$sd_2
## z = -2.5155, n = 31, p-value = 0.01189
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -149.0000000 3461.6666667 -0.3204301
summer_sd_sens_409 <- sens.slope(summer_standard_dev_all_409$sd_2)
print(summer_sd_sens_409)
##
## Sen's slope
##
## data: summer_standard_dev_all_409$sd_2
## z = -2.5155, n = 31, p-value = 0.01189
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.038866491 -0.005256155
## sample estimates:
## Sen's slope
## -0.02168085
Winter
winter_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_409 <- winter_standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.974665 |
| 1988 | 5.050618 |
| 1989 | 5.963432 |
| 1990 | 5.072568 |
| 1991 | 9.255566 |
| 1992 | 3.887826 |
| 1993 | 4.419525 |
| 1996 | 4.960474 |
| 1997 | 5.077696 |
| 1998 | 4.351677 |
| 1999 | 4.609097 |
| 2000 | 5.096944 |
| 2001 | 4.037615 |
| 2002 | 5.456137 |
| 2003 | 4.065797 |
| 2004 | 5.694467 |
| 2006 | 4.758845 |
| 2007 | 5.588388 |
| 2008 | 5.736017 |
| 2009 | 4.720634 |
| 2010 | 4.679158 |
| 2011 | 5.453618 |
| 2012 | 4.304992 |
| 2013 | 5.799034 |
| 2014 | 4.276036 |
| 2015 | 4.901297 |
| 2016 | 4.821083 |
| 2017 | 5.439126 |
| 2018 | 4.287877 |
| 2020 | 4.486729 |
| 2021 | 4.553974 |
ggplot(winter_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average winter temperatures for water years 2005-2021
winter_sd_mk_409 <- mk.test(winter_standard_dev_all_409$sd_2)
print(winter_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_409$sd_2
## z = -0.20396, n = 31, p-value = 0.8384
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -13.00000000 3461.66666667 -0.02795699
winter_sd_sens_409 <- sens.slope(winter_standard_dev_all_409$sd_2)
print(winter_sd_sens_409)
##
## Sen's slope
##
## data: winter_standard_dev_all_409$sd_2
## z = -0.20396, n = 31, p-value = 0.8384
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02857741 0.02535644
## sample estimates:
## Sen's slope
## -0.003357913
Summer
summer_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_409_ad <- summer_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.397257 |
| 1988 | 2.467455 |
| 1989 | 3.043151 |
| 1990 | 2.782934 |
| 1991 | 2.541100 |
| 1992 | 2.840267 |
| 1993 | 3.080035 |
| 1996 | 2.115474 |
| 1997 | 2.283789 |
| 1998 | 3.364712 |
| 1999 | 2.563222 |
| 2000 | 2.334997 |
| 2001 | 2.741874 |
| 2002 | 2.605418 |
| 2003 | 2.980548 |
| 2004 | 2.449967 |
| 2006 | 2.423603 |
| 2007 | 2.485783 |
| 2008 | 2.893246 |
| 2009 | 3.016834 |
| 2010 | 2.633838 |
| 2011 | 2.339611 |
| 2012 | 2.098329 |
| 2013 | 2.264628 |
| 2014 | 2.576926 |
| 2015 | 2.599574 |
| 2016 | 2.616173 |
| 2017 | 1.982405 |
| 2018 | 2.041701 |
| 2020 | 2.972061 |
| 2021 | 2.789555 |
ggplot(summer_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average summer temperatures for water years 1986-2021
summer_sd_mk_409_ad <- mk.test(summer_standard_dev_all_409_ad$sd_2)
print(summer_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_409_ad$sd_2
## z = -0.74784, n = 31, p-value = 0.4546
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -45.00000000 3461.66666667 -0.09677419
summer_sd_sens_409_ad <- sens.slope(summer_standard_dev_all_409_ad$sd_2)
print(summer_sd_sens_409_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_409_ad$sd_2
## z = -0.74784, n = 31, p-value = 0.4546
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02271076 0.00955598
## sample estimates:
## Sen's slope
## -0.006392215
Winter
winter_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_409_ad <- winter_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.788636 |
| 1988 | 4.826210 |
| 1989 | 5.700734 |
| 1990 | 4.801105 |
| 1991 | 8.565800 |
| 1992 | 3.698072 |
| 1993 | 4.211914 |
| 1996 | 4.706185 |
| 1997 | 4.815921 |
| 1998 | 4.124337 |
| 1999 | 4.362321 |
| 2000 | 4.798292 |
| 2001 | 3.841369 |
| 2002 | 5.169463 |
| 2003 | 3.855594 |
| 2004 | 5.409684 |
| 2006 | 4.759061 |
| 2007 | 5.588655 |
| 2008 | 5.736270 |
| 2009 | 4.720979 |
| 2010 | 4.678857 |
| 2011 | 5.453842 |
| 2012 | 4.305625 |
| 2013 | 5.799172 |
| 2014 | 4.276260 |
| 2015 | 4.901030 |
| 2016 | 4.820488 |
| 2017 | 5.439025 |
| 2018 | 4.288632 |
| 2020 | 4.486501 |
| 2021 | 4.553365 |
ggplot(winter_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average winter temperatures for water years 1986-2021
winter_sd_mk_409_ad <- mk.test(winter_standard_dev_all_409_ad$sd_2)
print(winter_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_409_ad$sd_2
## z = 0.4759, n = 31, p-value = 0.6341
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.900000e+01 3.461667e+03 6.236559e-02
winter_sd_sens_409_ad <- sens.slope(winter_standard_dev_all_409_ad$sd_2)
print(winter_sd_sens_409_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_409_ad$sd_2
## z = 0.4759, n = 31, p-value = 0.6341
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01811271 0.03683579
## sample estimates:
## Sen's slope
## 0.00478274
spring_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_409 <- spring_standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.707578 |
| 1988 | 5.178943 |
| 1989 | 4.525912 |
| 1990 | 3.678747 |
| 1991 | 6.179767 |
| 1992 | 3.371805 |
| 1993 | 4.947870 |
| 1996 | 5.297210 |
| 1997 | 5.644640 |
| 1998 | 4.925489 |
| 1999 | 5.473893 |
| 2000 | 4.954143 |
| 2001 | 5.417544 |
| 2002 | 4.200319 |
| 2003 | 5.688573 |
| 2004 | 4.383031 |
| 2006 | 4.356494 |
| 2007 | 4.437282 |
| 2008 | 4.631997 |
| 2009 | 5.025526 |
| 2010 | 4.867779 |
| 2011 | 4.278251 |
| 2012 | 4.230795 |
| 2013 | 5.151387 |
| 2014 | 5.209650 |
| 2015 | 3.640119 |
| 2016 | 3.994094 |
| 2017 | 4.337445 |
| 2018 | 4.544805 |
| 2020 | 4.723522 |
| 2021 | 4.047140 |
ggplot(spring_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average spring temperatures for water years 2005-2021
spring_sd_mk_409 <- mk.test(spring_standard_dev_all_409$sd_2)
print(spring_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_409$sd_2
## z = -1.1897, n = 31, p-value = 0.2341
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -71.0000000 3461.6666667 -0.1526882
spring_sd_sens_409 <- sens.slope(spring_standard_dev_all_409$sd_2)
print(spring_sd_sens_409)
##
## Sen's slope
##
## data: spring_standard_dev_all_409$sd_2
## z = -1.1897, n = 31, p-value = 0.2341
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04789236 0.01371074
## sample estimates:
## Sen's slope
## -0.02003599
Fall
fall_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_409 <- fall_standard_dev_all_409 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.636718 |
| 1988 | 4.160683 |
| 1989 | 3.345969 |
| 1990 | 5.937602 |
| 1991 | 4.258117 |
| 1992 | 5.611783 |
| 1993 | 4.137422 |
| 1996 | 4.844622 |
| 1997 | 6.185359 |
| 1998 | 5.901995 |
| 1999 | 4.262590 |
| 2000 | 4.579570 |
| 2001 | 5.494465 |
| 2002 | 4.149668 |
| 2003 | 5.046301 |
| 2004 | 4.267020 |
| 2006 | 3.842780 |
| 2007 | 5.372472 |
| 2008 | 4.200420 |
| 2009 | 4.462027 |
| 2010 | 6.069590 |
| 2011 | 4.376262 |
| 2012 | 4.838276 |
| 2013 | 4.514412 |
| 2014 | 5.644334 |
| 2015 | 3.644617 |
| 2016 | 3.935459 |
| 2017 | 4.153583 |
| 2018 | 4.546022 |
| 2020 | 7.005615 |
| 2021 | 5.495603 |
ggplot(fall_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_409 <- mk.test(fall_standard_dev_all_409$sd_2)
print(fall_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_409$sd_2
## z = 0.23795, n = 31, p-value = 0.8119
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.500000e+01 3.461667e+03 3.225806e-02
fall_sd_sens_409 <- sens.slope(fall_standard_dev_all_409$sd_2)
print(fall_sd_sens_409)
##
## Sen's slope
##
## data: fall_standard_dev_all_409$sd_2
## z = 0.23795, n = 31, p-value = 0.8119
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02946421 0.03905979
## sample estimates:
## Sen's slope
## 0.001749422
Spring
spring_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_409_ad <- spring_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.384167 |
| 1988 | 4.727168 |
| 1989 | 4.107563 |
| 1990 | 3.348476 |
| 1991 | 5.632144 |
| 1992 | 3.051591 |
| 1993 | 4.536925 |
| 1996 | 4.820210 |
| 1997 | 5.196423 |
| 1998 | 4.507531 |
| 1999 | 5.033528 |
| 2000 | 4.492173 |
| 2001 | 4.942421 |
| 2002 | 3.797767 |
| 2003 | 5.171657 |
| 2004 | 3.980346 |
| 2006 | 4.357225 |
| 2007 | 4.437368 |
| 2008 | 4.632239 |
| 2009 | 5.025759 |
| 2010 | 4.867982 |
| 2011 | 4.277749 |
| 2012 | 4.231114 |
| 2013 | 5.151556 |
| 2014 | 5.209977 |
| 2015 | 3.639209 |
| 2016 | 3.994249 |
| 2017 | 4.337315 |
| 2018 | 4.545222 |
| 2020 | 4.723710 |
| 2021 | 4.048348 |
ggplot(spring_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average spring temperatures for water years 1986-2021
spring_sd_mk_409_ad <- mk.test(spring_standard_dev_all_409_ad$sd_2)
print(spring_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_409_ad$sd_2
## z = 0.067986, n = 31, p-value = 0.9458
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 5.000000e+00 3.461667e+03 1.075269e-02
spring_sd_sens_409_ad <- sens.slope(spring_standard_dev_all_409_ad$sd_2)
print(spring_sd_sens_409_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_409_ad$sd_2
## z = 0.067986, n = 31, p-value = 0.9458
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02362163 0.03419145
## sample estimates:
## Sen's slope
## 0.00126397
Fall
fall_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_409_ad <- fall_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.215531 |
| 1988 | 3.754335 |
| 1989 | 3.009366 |
| 1990 | 5.388643 |
| 1991 | 3.880544 |
| 1992 | 5.150724 |
| 1993 | 3.748401 |
| 1996 | 4.393330 |
| 1997 | 5.661473 |
| 1998 | 5.377894 |
| 1999 | 3.869444 |
| 2000 | 4.142664 |
| 2001 | 4.969756 |
| 2002 | 3.758682 |
| 2003 | 4.580624 |
| 2004 | 3.853770 |
| 2006 | 3.843251 |
| 2007 | 5.372701 |
| 2008 | 4.201383 |
| 2009 | 4.461759 |
| 2010 | 6.069164 |
| 2011 | 4.375958 |
| 2012 | 4.838542 |
| 2013 | 4.513693 |
| 2014 | 5.644654 |
| 2015 | 3.645144 |
| 2016 | 3.934910 |
| 2017 | 4.153713 |
| 2018 | 4.545930 |
| 2020 | 7.005864 |
| 2021 | 5.495211 |
ggplot(fall_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_409_ad <- mk.test(fall_standard_dev_all_409_ad$sd_2)
print(fall_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_409_ad$sd_2
## z = 1.4957, n = 31, p-value = 0.1347
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 89.0000000 3461.6666667 0.1913978
fall_sd_sens_409_ad <- sens.slope(fall_standard_dev_all_409_ad$sd_2)
print(fall_sd_sens_409_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_409_ad$sd_2
## z = 1.4957, n = 31, p-value = 0.1347
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.004365531 0.062102568
## sample estimates:
## Sen's slope
## 0.02607812
Morrisey 7/21/2005
snotel_426 <- SNOTEL_yampa_area %>%
filter(site_id == "426")
#str(snotel_426) # check the date, usually a character.
snotel_426$Date <- as.Date(snotel_426$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_426_clean <- snotel_426 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_426_clean <- snotel_426_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_426_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_426_clean <- snotel_426_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -50) %>%
filter(temperature_mean < 40)
ggplot(snotel_426_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_426_cull_count <- snotel_426_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_426_cull_count
# filtering for too few observations in a year
snotel_426_cull_count_days <- snotel_426_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_426_cull_count_days
## # A tibble: 2 x 2
## # Groups: waterYear [2]
## waterYear n
## <dbl> <int>
## 1 2009 340
## 2 2021 349
snotel_426_clean_culled <- snotel_426_clean %>%
filter(waterYear != "2009" & waterYear != "2021")# & waterYear != "2005" & waterYear != "2019" & waterYear != "2022")# & waterYear != "1986" & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_426_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_426_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_426_xts <- xts(snotel_426_clean_culled$temperature_mean, order.by = snotel_426_clean_culled$Date)
dygraph(temp_426_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_426_clean_culled <- snotel_426_clean_culled %>%
# filter(temperature_mean > -30)
#temp_426_xts <- xts(snotel_426_clean_culled$temperature_mean, order.by = snotel_426_clean_culled$Date)
#dygraph(temp_426_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_426_adjusted <- snotel_426_clean_culled %>%
mutate(temp_ad = if_else(Date < "2005-07-21", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_426 <- snotel_426_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_426 <- yearly_wy_aver_426 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_426 <- daily_wy_aver_426 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_426$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_426 <-daily_wy_aver_426 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_426$date_temp <- signif(daily_wy_aver2_426$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_426, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_426 <- daily_wy_aver_426 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_426 <- standard_dev_426 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_426 <- standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.642717 |
| 1988 | 8.008775 |
| 1989 | 9.449036 |
| 1990 | 8.683053 |
| 1991 | 9.170577 |
| 1992 | 8.537791 |
| 1993 | 8.676514 |
| 1994 | 9.525407 |
| 1995 | 8.192424 |
| 1996 | 8.622041 |
| 1997 | 8.670823 |
| 1998 | 8.768147 |
| 1999 | 7.907919 |
| 2000 | 8.392275 |
| 2001 | 9.164446 |
| 2002 | 9.813834 |
| 2003 | 8.961799 |
| 2004 | 8.571169 |
| 2005 | 8.096051 |
| 2006 | 8.582421 |
| 2007 | 8.845773 |
| 2008 | 8.787455 |
| 2010 | 8.872551 |
| 2011 | 8.348895 |
| 2012 | 8.502421 |
| 2013 | 8.997153 |
| 2014 | 8.050838 |
| 2015 | 7.657484 |
| 2016 | 8.378217 |
| 2017 | 8.126881 |
| 2018 | 8.079436 |
| 2019 | 8.651915 |
| 2020 | 8.964956 |
| 2022 | 8.545430 |
ggplot(standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average temperatures for water years 2005-2021
sd_mk_426 <- mk.test(standard_dev_all_426$sd_2)
print(sd_mk_426)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_426$sd_2
## z = -1.2749, n = 34, p-value = 0.2023
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -87.0000000 4550.3333333 -0.1550802
sd_sens_426 <- sens.slope(standard_dev_all_426$sd_2)
print(sd_sens_426)
##
## Sen's slope
##
## data: standard_dev_all_426$sd_2
## z = -1.2749, n = 34, p-value = 0.2023
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02882424 0.00714949
## sample estimates:
## Sen's slope
## -0.009821212
#using the clean culled df:
#average water year temperature
yearly_wy_aver_426_ad <- snotel_426_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_426_ad <- yearly_wy_aver_426_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_426_ad <- daily_wy_aver_426_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_426_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_426_ad <-daily_wy_aver_426_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_426_ad$date_temp_ad <- signif(daily_wy_aver2_426_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_426_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_426_ad <- daily_wy_aver_426_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_426_ad <- standard_dev_426_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_426_ad <- standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.032449 |
| 1988 | 7.469399 |
| 1989 | 8.830085 |
| 1990 | 8.043543 |
| 1991 | 8.571182 |
| 1992 | 7.909178 |
| 1993 | 8.068779 |
| 1994 | 8.814518 |
| 1995 | 7.580772 |
| 1996 | 7.973712 |
| 1997 | 8.044413 |
| 1998 | 8.100725 |
| 1999 | 7.332358 |
| 2000 | 7.718765 |
| 2001 | 8.465805 |
| 2002 | 9.079917 |
| 2003 | 8.257697 |
| 2004 | 7.940383 |
| 2005 | 7.444764 |
| 2006 | 8.582735 |
| 2007 | 8.846403 |
| 2008 | 8.788093 |
| 2010 | 8.872827 |
| 2011 | 8.349023 |
| 2012 | 8.502544 |
| 2013 | 8.997369 |
| 2014 | 8.051074 |
| 2015 | 7.658079 |
| 2016 | 8.378828 |
| 2017 | 8.126888 |
| 2018 | 8.080106 |
| 2019 | 8.652534 |
| 2020 | 8.965133 |
| 2022 | 8.546170 |
ggplot(standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average temperatures for water years 1986-2021
sd_mk_426_ad <- mk.test(standard_dev_all_426_ad$sd_2)
print(sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_426_ad$sd_2
## z = 1.9272, n = 34, p-value = 0.05396
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 131.0000000 4550.3333333 0.2335116
sd_sens_426_ad <- sens.slope(standard_dev_all_426_ad$sd_2)
print(sd_sens_426_ad)
##
## Sen's slope
##
## data: standard_dev_all_426_ad$sd_2
## z = 1.9272, n = 34, p-value = 0.05396
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0008852415 0.0327236747
## sample estimates:
## Sen's slope
## 0.01613353
summer_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_426 <- summer_standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.739273 |
| 1988 | 8.232363 |
| 1989 | 3.755190 |
| 1990 | 3.513091 |
| 1991 | 2.978507 |
| 1992 | 3.381077 |
| 1993 | 3.423649 |
| 1994 | 2.488878 |
| 1995 | 3.708416 |
| 1996 | 2.392089 |
| 1997 | 2.375829 |
| 1998 | 3.681509 |
| 1999 | 2.602088 |
| 2000 | 2.758283 |
| 2001 | 3.045960 |
| 2002 | 3.062041 |
| 2003 | 3.729209 |
| 2004 | 3.103744 |
| 2005 | 3.384100 |
| 2006 | 2.505016 |
| 2007 | 2.905791 |
| 2008 | 3.209992 |
| 2010 | 2.870135 |
| 2011 | 2.292667 |
| 2012 | 2.357906 |
| 2013 | 2.230090 |
| 2014 | 2.569672 |
| 2015 | 2.303341 |
| 2016 | 2.283306 |
| 2017 | 2.271566 |
| 2018 | 2.545910 |
| 2019 | 3.091264 |
| 2020 | 2.971545 |
| 2022 | 2.478854 |
ggplot(summer_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average summer temperatures for water years 2005-2021
summer_sd_mk_426 <- mk.test(summer_standard_dev_all_426$sd_2)
print(summer_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_426$sd_2
## z = -3.0835, n = 34, p-value = 0.002046
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -209.000000 4550.333333 -0.372549
summer_sd_sens_426 <- sens.slope(summer_standard_dev_all_426$sd_2)
print(summer_sd_sens_426)
##
## Sen's slope
##
## data: summer_standard_dev_all_426$sd_2
## z = -3.0835, n = 34, p-value = 0.002046
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.047188832 -0.009789135
## sample estimates:
## Sen's slope
## -0.02946818
Winter
winter_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_426 <- winter_standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.852286 |
| 1988 | 5.337589 |
| 1989 | 6.985771 |
| 1990 | 5.280096 |
| 1991 | 6.042907 |
| 1992 | 4.392419 |
| 1993 | 5.015693 |
| 1994 | 5.078328 |
| 1995 | 5.202707 |
| 1996 | 5.380408 |
| 1997 | 5.585838 |
| 1998 | 4.583953 |
| 1999 | 5.516878 |
| 2000 | 4.852133 |
| 2001 | 4.311311 |
| 2002 | 5.732712 |
| 2003 | 4.788324 |
| 2004 | 5.661703 |
| 2005 | 4.546253 |
| 2006 | 5.512357 |
| 2007 | 5.937986 |
| 2008 | 5.814025 |
| 2010 | 5.216895 |
| 2011 | 5.500211 |
| 2012 | 5.053515 |
| 2013 | 6.012256 |
| 2014 | 5.013055 |
| 2015 | 5.424139 |
| 2016 | 5.162728 |
| 2017 | 6.334871 |
| 2018 | 4.877927 |
| 2019 | 4.525921 |
| 2020 | 5.008637 |
| 2022 | 5.773965 |
ggplot(winter_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average winter temperatures for water years 2005-2021
winter_sd_mk_426 <- mk.test(winter_standard_dev_all_426$sd_2)
print(winter_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_426$sd_2
## z = 0.14824, n = 34, p-value = 0.8821
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.100000e+01 4.550333e+03 1.960784e-02
winter_sd_sens_426 <- sens.slope(winter_standard_dev_all_426$sd_2)
print(winter_sd_sens_426)
##
## Sen's slope
##
## data: winter_standard_dev_all_426$sd_2
## z = 0.14824, n = 34, p-value = 0.8821
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02160900 0.02811109
## sample estimates:
## Sen's slope
## 0.002429534
Summer
summer_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_426_ad <- summer_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.458122 |
| 1988 | 7.494216 |
| 1989 | 3.370875 |
| 1990 | 3.154570 |
| 1991 | 2.673157 |
| 1992 | 3.035828 |
| 1993 | 3.079084 |
| 1994 | 2.227724 |
| 1995 | 3.329573 |
| 1996 | 2.142229 |
| 1997 | 2.129286 |
| 1998 | 3.309416 |
| 1999 | 2.333496 |
| 2000 | 2.470209 |
| 2001 | 2.736394 |
| 2002 | 2.744483 |
| 2003 | 3.342295 |
| 2004 | 2.784337 |
| 2005 | 3.088566 |
| 2006 | 2.505148 |
| 2007 | 2.906600 |
| 2008 | 3.210458 |
| 2010 | 2.871500 |
| 2011 | 2.292271 |
| 2012 | 2.357838 |
| 2013 | 2.231821 |
| 2014 | 2.571204 |
| 2015 | 2.302342 |
| 2016 | 2.283829 |
| 2017 | 2.272686 |
| 2018 | 2.546904 |
| 2019 | 3.090988 |
| 2020 | 2.972224 |
| 2022 | 2.479747 |
ggplot(summer_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average summer temperatures for water years 1986-2021
summer_sd_mk_426_ad <- mk.test(summer_standard_dev_all_426_ad$sd_2)
print(summer_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_426_ad$sd_2
## z = -1.5121, n = 34, p-value = 0.1305
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -103.0000000 4550.3333333 -0.1836007
summer_sd_sens_426_ad <- sens.slope(summer_standard_dev_all_426_ad$sd_2)
print(summer_sd_sens_426_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_426_ad$sd_2
## z = -1.5121, n = 34, p-value = 0.1305
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.033319625 0.003104887
## sample estimates:
## Sen's slope
## -0.01350774
Winter
winter_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_426_ad <- winter_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.694202 |
| 1988 | 5.153704 |
| 1989 | 6.754797 |
| 1990 | 5.057492 |
| 1991 | 5.912022 |
| 1992 | 4.221615 |
| 1993 | 4.848143 |
| 1994 | 4.894501 |
| 1995 | 4.971193 |
| 1996 | 5.148331 |
| 1997 | 5.337192 |
| 1998 | 4.377849 |
| 1999 | 5.283918 |
| 2000 | 4.603725 |
| 2001 | 4.149053 |
| 2002 | 5.489818 |
| 2003 | 4.576858 |
| 2004 | 5.392288 |
| 2005 | 4.369330 |
| 2006 | 5.512281 |
| 2007 | 5.938353 |
| 2008 | 5.814081 |
| 2010 | 5.216456 |
| 2011 | 5.499572 |
| 2012 | 5.053413 |
| 2013 | 6.011248 |
| 2014 | 5.013140 |
| 2015 | 5.424199 |
| 2016 | 5.163010 |
| 2017 | 6.334732 |
| 2018 | 4.877728 |
| 2019 | 4.525837 |
| 2020 | 5.007917 |
| 2022 | 5.774357 |
ggplot(winter_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average winter temperatures for water years 1986-2021
winter_sd_mk_426_ad <- mk.test(winter_standard_dev_all_426_ad$sd_2)
print(winter_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_426_ad$sd_2
## z = 1.0377, n = 34, p-value = 0.2994
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 71.0000000 4550.3333333 0.1265597
winter_sd_sens_426_ad <- sens.slope(winter_standard_dev_all_426_ad$sd_2)
print(winter_sd_sens_426_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_426_ad$sd_2
## z = 1.0377, n = 34, p-value = 0.2994
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.009516406 0.036027205
## sample estimates:
## Sen's slope
## 0.01278616
spring_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_426 <- spring_standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.221554 |
| 1988 | 5.076123 |
| 1989 | 5.078512 |
| 1990 | 4.034156 |
| 1991 | 5.332270 |
| 1992 | 3.520110 |
| 1993 | 4.722456 |
| 1994 | 5.010741 |
| 1995 | 3.316790 |
| 1996 | 4.849968 |
| 1997 | 5.853916 |
| 1998 | 4.620635 |
| 1999 | 5.104850 |
| 2000 | 5.270240 |
| 2001 | 4.634480 |
| 2002 | 4.049409 |
| 2003 | 5.535536 |
| 2004 | 4.465426 |
| 2005 | 4.453821 |
| 2006 | 4.100473 |
| 2007 | 4.425696 |
| 2008 | 5.208880 |
| 2010 | 4.668127 |
| 2011 | 4.180380 |
| 2012 | 4.079903 |
| 2013 | 5.294261 |
| 2014 | 5.235661 |
| 2015 | 3.113942 |
| 2016 | 3.749447 |
| 2017 | 4.259069 |
| 2018 | 4.651310 |
| 2019 | 3.531353 |
| 2020 | 4.957340 |
| 2022 | 5.076989 |
ggplot(spring_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average spring temperatures for water years 2005-2021
spring_sd_mk_426 <- mk.test(spring_standard_dev_all_426$sd_2)
print(spring_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_426$sd_2
## z = -0.77087, n = 34, p-value = 0.4408
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -53.00000000 4550.33333333 -0.09447415
spring_sd_sens_426 <- sens.slope(spring_standard_dev_all_426$sd_2)
print(spring_sd_sens_426)
##
## Sen's slope
##
## data: spring_standard_dev_all_426$sd_2
## z = -0.77087, n = 34, p-value = 0.4408
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03900288 0.01429879
## sample estimates:
## Sen's slope
## -0.01138834
Fall
fall_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_426 <- fall_standard_dev_all_426 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.472871 |
| 1988 | 3.850857 |
| 1989 | 6.005770 |
| 1990 | 5.751495 |
| 1991 | 4.596352 |
| 1992 | 5.910865 |
| 1993 | 4.149456 |
| 1994 | 5.450159 |
| 1995 | 4.971737 |
| 1996 | 5.437538 |
| 1997 | 6.072069 |
| 1998 | 5.985415 |
| 1999 | 4.133686 |
| 2000 | 5.087098 |
| 2001 | 4.849990 |
| 2002 | 4.581478 |
| 2003 | 4.897720 |
| 2004 | 4.093865 |
| 2005 | 4.757118 |
| 2006 | 4.175156 |
| 2007 | 5.474201 |
| 2008 | 3.827106 |
| 2010 | 6.164694 |
| 2011 | 4.343076 |
| 2012 | 4.916697 |
| 2013 | 4.788296 |
| 2014 | 5.214758 |
| 2015 | 3.854771 |
| 2016 | 4.037565 |
| 2017 | 4.517873 |
| 2018 | 5.526220 |
| 2019 | 5.581508 |
| 2020 | 7.684063 |
| 2022 | 4.883665 |
ggplot(fall_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_426 <- mk.test(fall_standard_dev_all_426$sd_2)
print(fall_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_426$sd_2
## z = -0.17789, n = 34, p-value = 0.8588
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -13.00000000 4550.33333333 -0.02317291
fall_sd_sens_426 <- sens.slope(fall_standard_dev_all_426$sd_2)
print(fall_sd_sens_426)
##
## Sen's slope
##
## data: fall_standard_dev_all_426$sd_2
## z = -0.17789, n = 34, p-value = 0.8588
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03619694 0.02746718
## sample estimates:
## Sen's slope
## -0.00344002
Spring
spring_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_426_ad <- spring_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.873669 |
| 1988 | 4.676009 |
| 1989 | 4.634301 |
| 1990 | 3.709031 |
| 1991 | 4.926260 |
| 1992 | 3.199963 |
| 1993 | 4.344552 |
| 1994 | 4.576298 |
| 1995 | 3.059967 |
| 1996 | 4.448273 |
| 1997 | 5.441559 |
| 1998 | 4.222515 |
| 1999 | 4.710157 |
| 2000 | 4.793349 |
| 2001 | 4.230930 |
| 2002 | 3.667650 |
| 2003 | 5.049386 |
| 2004 | 4.060895 |
| 2005 | 4.056381 |
| 2006 | 4.100967 |
| 2007 | 4.427821 |
| 2008 | 5.208052 |
| 2010 | 4.668077 |
| 2011 | 4.180491 |
| 2012 | 4.079769 |
| 2013 | 5.296038 |
| 2014 | 5.234502 |
| 2015 | 3.114251 |
| 2016 | 3.749632 |
| 2017 | 4.260744 |
| 2018 | 4.652719 |
| 2019 | 3.533648 |
| 2020 | 4.957481 |
| 2022 | 5.078111 |
ggplot(spring_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average spring temperatures for water years 1986-2021
spring_sd_mk_426_ad <- mk.test(spring_standard_dev_all_426_ad$sd_2)
print(spring_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_426_ad$sd_2
## z = 0.56333, n = 34, p-value = 0.5732
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.900000e+01 4.550333e+03 6.951872e-02
spring_sd_sens_426_ad <- sens.slope(spring_standard_dev_all_426_ad$sd_2)
print(spring_sd_sens_426_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_426_ad$sd_2
## z = 0.56333, n = 34, p-value = 0.5732
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0216100 0.0317133
## sample estimates:
## Sen's slope
## 0.008587489
Fall
fall_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_426_ad <- fall_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.076290 |
| 1988 | 3.542865 |
| 1989 | 5.478899 |
| 1990 | 5.240837 |
| 1991 | 4.192554 |
| 1992 | 5.461554 |
| 1993 | 3.767812 |
| 1994 | 4.983270 |
| 1995 | 4.510417 |
| 1996 | 4.959602 |
| 1997 | 5.576359 |
| 1998 | 5.463393 |
| 1999 | 3.766024 |
| 2000 | 4.629363 |
| 2001 | 4.391385 |
| 2002 | 4.159132 |
| 2003 | 4.462521 |
| 2004 | 3.703572 |
| 2005 | 4.231928 |
| 2006 | 4.173330 |
| 2007 | 5.474218 |
| 2008 | 3.830206 |
| 2010 | 6.163635 |
| 2011 | 4.343450 |
| 2012 | 4.913222 |
| 2013 | 4.786235 |
| 2014 | 5.213006 |
| 2015 | 3.857337 |
| 2016 | 4.036434 |
| 2017 | 4.512310 |
| 2018 | 5.526305 |
| 2019 | 5.581952 |
| 2020 | 7.683041 |
| 2022 | 4.882356 |
ggplot(fall_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_426_ad <- mk.test(fall_standard_dev_all_426_ad$sd_2)
print(fall_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_426_ad$sd_2
## z = 1.1267, n = 34, p-value = 0.2599
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 77.0000000 4550.3333333 0.1372549
fall_sd_sens_426_ad <- sens.slope(fall_standard_dev_all_426_ad$sd_2)
print(fall_sd_sens_426_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_426_ad$sd_2
## z = 1.1267, n = 34, p-value = 0.2599
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01183563 0.04489565
## sample estimates:
## Sen's slope
## 0.01372829
Oyler -> Morrisey 7/30/2003
snotel_457 <- SNOTEL_yampa_area %>%
filter(site_id == "457")
#str(snotel_457) # check the date, usually a character.
snotel_457$Date <- as.Date(snotel_457$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_457_clean <- snotel_457 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_457_clean <- snotel_457_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_457_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_457_clean <- snotel_457_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_457_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_457_cull_count <- snotel_457_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_457_cull_count
# filtering for too few observations in a year
snotel_457_cull_count_days <- snotel_457_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_457_cull_count_days
## # A tibble: 6 x 2
## # Groups: waterYear [6]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1994 332
## 3 1996 349
## 4 1997 329
## 5 2003 346
## 6 2021 346
snotel_457_clean_culled <- snotel_457_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1994" & waterYear != "1996" & waterYear != "1997" & waterYear != "2003" & waterYear != "2021")# & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_457_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Also 1986
ggplot(snotel_457_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_457_xts <- xts(snotel_457_clean_culled$temperature_mean, order.by = snotel_457_clean_culled$Date)
dygraph(temp_457_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_457_clean_culled <- snotel_457_clean_culled %>%
# filter(temperature_mean > -30)
#temp_457_xts <- xts(snotel_457_clean_culled$temperature_mean, order.by = snotel_457_clean_culled$Date)
#dygraph(temp_457_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_457_adjusted <- snotel_457_clean_culled %>%
mutate(temp_ad = if_else(Date < "2003-07-30", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_457 <- snotel_457_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_457 <- yearly_wy_aver_457 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_457 <- daily_wy_aver_457 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_457$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_457 <-daily_wy_aver_457 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_457$date_temp <- signif(daily_wy_aver2_457$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_457, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_457 <- daily_wy_aver_457 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_457 <- standard_dev_457 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_457 <- standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.892848 |
| 1988 | 9.953110 |
| 1989 | 9.757795 |
| 1990 | 9.176039 |
| 1991 | 9.421986 |
| 1992 | 8.507405 |
| 1993 | 8.878013 |
| 1995 | 8.358076 |
| 1998 | 9.150633 |
| 1999 | 8.440975 |
| 2000 | 8.736877 |
| 2001 | 9.645923 |
| 2002 | 10.040430 |
| 2004 | 8.051569 |
| 2005 | 7.863386 |
| 2006 | 8.768314 |
| 2007 | 9.036800 |
| 2008 | 8.900491 |
| 2009 | 7.976123 |
| 2010 | 8.677359 |
| 2011 | 8.610741 |
| 2012 | 8.805624 |
| 2013 | 9.212073 |
| 2014 | 8.350688 |
| 2015 | 7.879517 |
| 2016 | 8.589405 |
| 2017 | 8.326662 |
| 2018 | 8.323975 |
| 2019 | 8.654312 |
| 2020 | 9.071537 |
| 2022 | 8.555147 |
ggplot(standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average temperatures for water years 2005-2021
sd_mk_457 <- mk.test(standard_dev_all_457$sd_2)
print(sd_mk_457)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_457$sd_2
## z = -2.3795, n = 31, p-value = 0.01734
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -141.0000000 3461.6666667 -0.3032258
sd_sens_457 <- sens.slope(standard_dev_all_457$sd_2)
print(sd_sens_457)
##
## Sen's slope
##
## data: standard_dev_all_457$sd_2
## z = -2.3795, n = 31, p-value = 0.01734
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.049787462 -0.005081117
## sample estimates:
## Sen's slope
## -0.02638274
#using the clean culled df:
#average water year temperature
yearly_wy_aver_457_ad <- snotel_457_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_457_ad <- yearly_wy_aver_457_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_457_ad <- daily_wy_aver_457_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_457_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_457_ad <-daily_wy_aver_457_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_457_ad$date_temp_ad <- signif(daily_wy_aver2_457_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_457_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_457_ad <- daily_wy_aver_457_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_457_ad <- standard_dev_457_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_457_ad <- standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.200529 |
| 1988 | 9.184255 |
| 1989 | 9.050691 |
| 1990 | 8.442843 |
| 1991 | 8.739959 |
| 1992 | 7.843690 |
| 1993 | 8.207632 |
| 1995 | 7.712921 |
| 1998 | 8.438042 |
| 1999 | 7.811811 |
| 2000 | 8.022352 |
| 2001 | 8.894507 |
| 2002 | 9.283490 |
| 2004 | 8.051478 |
| 2005 | 7.863308 |
| 2006 | 8.768371 |
| 2007 | 9.036790 |
| 2008 | 8.900641 |
| 2009 | 7.976349 |
| 2010 | 8.677249 |
| 2011 | 8.611094 |
| 2012 | 8.805285 |
| 2013 | 9.211821 |
| 2014 | 8.350803 |
| 2015 | 7.879602 |
| 2016 | 8.589409 |
| 2017 | 8.326313 |
| 2018 | 8.323899 |
| 2019 | 8.654521 |
| 2020 | 9.071250 |
| 2022 | 8.555395 |
ggplot(standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average temperatures for water years 1986-2021
sd_mk_457_ad <- mk.test(standard_dev_all_457_ad$sd_2)
print(sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_457_ad$sd_2
## z = 0.44191, n = 31, p-value = 0.6586
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.700000e+01 3.461667e+03 5.806452e-02
sd_sens_457_ad <- sens.slope(standard_dev_all_457_ad$sd_2)
print(sd_sens_457_ad)
##
## Sen's slope
##
## data: standard_dev_all_457_ad$sd_2
## z = 0.44191, n = 31, p-value = 0.6586
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01772587 0.02844930
## sample estimates:
## Sen's slope
## 0.004837867
summer_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_457 <- summer_standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.992541 |
| 1988 | 2.687907 |
| 1989 | 3.843831 |
| 1990 | 4.043991 |
| 1991 | 2.949455 |
| 1992 | 3.364353 |
| 1993 | 4.307696 |
| 1995 | 3.610199 |
| 1998 | 4.120611 |
| 1999 | 2.647824 |
| 2000 | 2.953143 |
| 2001 | 3.358466 |
| 2002 | 3.133655 |
| 2004 | 2.902339 |
| 2005 | 3.884231 |
| 2006 | 2.554145 |
| 2007 | 3.160065 |
| 2008 | 3.472597 |
| 2009 | 2.985598 |
| 2010 | 2.622411 |
| 2011 | 2.667538 |
| 2012 | 2.477970 |
| 2013 | 2.224913 |
| 2014 | 2.859270 |
| 2015 | 2.240728 |
| 2016 | 2.156111 |
| 2017 | 2.206481 |
| 2018 | 2.616310 |
| 2019 | 3.198315 |
| 2020 | 2.997076 |
| 2022 | 2.636098 |
ggplot(summer_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average summer temperatures for water years 2005-2021
summer_sd_mk_457 <- mk.test(summer_standard_dev_all_457$sd_2)
print(summer_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_457$sd_2
## z = -3.1273, n = 31, p-value = 0.001764
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -185.0000000 3461.6666667 -0.3978495
summer_sd_sens_457 <- sens.slope(summer_standard_dev_all_457$sd_2)
print(summer_sd_sens_457)
##
## Sen's slope
##
## data: summer_standard_dev_all_457$sd_2
## z = -3.1273, n = 31, p-value = 0.001764
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.06032603 -0.01448454
## sample estimates:
## Sen's slope
## -0.03674804
Winter
winter_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_457 <- winter_standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.593995 |
| 1988 | 5.281395 |
| 1989 | 6.229539 |
| 1990 | 4.835539 |
| 1991 | 5.746470 |
| 1992 | 4.604115 |
| 1993 | 4.553218 |
| 1995 | 4.912552 |
| 1998 | 4.432972 |
| 1999 | 5.259262 |
| 2000 | 4.614434 |
| 2001 | 4.261931 |
| 2002 | 5.499143 |
| 2004 | 4.929292 |
| 2005 | 4.100556 |
| 2006 | 5.028178 |
| 2007 | 5.672004 |
| 2008 | 5.118083 |
| 2009 | 4.707177 |
| 2010 | 4.970254 |
| 2011 | 5.356081 |
| 2012 | 4.634603 |
| 2013 | 5.665082 |
| 2014 | 4.514378 |
| 2015 | 5.194922 |
| 2016 | 4.552165 |
| 2017 | 5.898778 |
| 2018 | 4.334583 |
| 2019 | 4.265698 |
| 2020 | 4.574603 |
| 2022 | 5.169657 |
ggplot(winter_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average winter temperatures for water years 2005-2021
winter_sd_mk_457 <- mk.test(winter_standard_dev_all_457$sd_2)
print(winter_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_457$sd_2
## z = -0.57788, n = 31, p-value = 0.5633
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -35.00000000 3461.66666667 -0.07526882
winter_sd_sens_457 <- sens.slope(winter_standard_dev_all_457$sd_2)
print(winter_sd_sens_457)
##
## Sen's slope
##
## data: winter_standard_dev_all_457$sd_2
## z = -0.57788, n = 31, p-value = 0.5633
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03239818 0.01711345
## sample estimates:
## Sen's slope
## -0.004985424
Summer
summer_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_457_ad <- summer_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.680248 |
| 1988 | 2.409237 |
| 1989 | 3.447738 |
| 1990 | 3.637108 |
| 1991 | 2.643716 |
| 1992 | 3.017216 |
| 1993 | 3.895168 |
| 1995 | 3.239005 |
| 1998 | 3.703040 |
| 1999 | 2.373072 |
| 2000 | 2.645531 |
| 2001 | 3.017343 |
| 2002 | 2.807620 |
| 2004 | 2.902313 |
| 2005 | 3.884463 |
| 2006 | 2.554887 |
| 2007 | 3.160920 |
| 2008 | 3.473218 |
| 2009 | 2.986190 |
| 2010 | 2.622275 |
| 2011 | 2.667888 |
| 2012 | 2.478036 |
| 2013 | 2.224681 |
| 2014 | 2.859777 |
| 2015 | 2.240512 |
| 2016 | 2.155809 |
| 2017 | 2.206518 |
| 2018 | 2.616237 |
| 2019 | 3.198689 |
| 2020 | 2.997516 |
| 2022 | 2.636536 |
ggplot(summer_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average summer temperatures for water years 1986-2021
summer_sd_mk_457_ad <- mk.test(summer_standard_dev_all_457_ad$sd_2)
print(summer_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_457_ad$sd_2
## z = -2.0056, n = 31, p-value = 0.0449
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -119.000000 3461.666667 -0.255914
summer_sd_sens_457_ad <- sens.slope(summer_standard_dev_all_457_ad$sd_2)
print(summer_sd_sens_457_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_457_ad$sd_2
## z = -2.0056, n = 31, p-value = 0.0449
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0433250019 -0.0004497269
## sample estimates:
## Sen's slope
## -0.02004248
Winter
winter_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_457_ad <- winter_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.412236 |
| 1988 | 5.068059 |
| 1989 | 6.021965 |
| 1990 | 4.610084 |
| 1991 | 5.601742 |
| 1992 | 4.399029 |
| 1993 | 4.351825 |
| 1995 | 4.693452 |
| 1998 | 4.244235 |
| 1999 | 5.060922 |
| 2000 | 4.380803 |
| 2001 | 4.093693 |
| 2002 | 5.275728 |
| 2004 | 4.929417 |
| 2005 | 4.100277 |
| 2006 | 5.028418 |
| 2007 | 5.671695 |
| 2008 | 5.118253 |
| 2009 | 4.707253 |
| 2010 | 4.970035 |
| 2011 | 5.356260 |
| 2012 | 4.633643 |
| 2013 | 5.664861 |
| 2014 | 4.514635 |
| 2015 | 5.194869 |
| 2016 | 4.552071 |
| 2017 | 5.898157 |
| 2018 | 4.334605 |
| 2019 | 4.265724 |
| 2020 | 4.574173 |
| 2022 | 5.169933 |
ggplot(winter_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average winter temperatures for water years 1986-2021
winter_sd_mk_457_ad <- mk.test(winter_standard_dev_all_457_ad$sd_2)
print(winter_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_457_ad$sd_2
## z = 0.16996, n = 31, p-value = 0.865
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.100000e+01 3.461667e+03 2.365591e-02
winter_sd_sens_457_ad <- sens.slope(winter_standard_dev_all_457_ad$sd_2)
print(winter_sd_sens_457_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_457_ad$sd_2
## z = 0.16996, n = 31, p-value = 0.865
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02433743 0.02684887
## sample estimates:
## Sen's slope
## 0.003506618
spring_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_457 <- spring_standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.761147 |
| 1988 | 5.281821 |
| 1989 | 4.609585 |
| 1990 | 3.711571 |
| 1991 | 5.415793 |
| 1992 | 3.675668 |
| 1993 | 4.573397 |
| 1995 | 3.236332 |
| 1998 | 4.366557 |
| 1999 | 5.305922 |
| 2000 | 4.995315 |
| 2001 | 4.368328 |
| 2002 | 4.239102 |
| 2004 | 3.883829 |
| 2005 | 4.121145 |
| 2006 | 4.034492 |
| 2007 | 4.413686 |
| 2008 | 4.945922 |
| 2009 | 4.693765 |
| 2010 | 4.714359 |
| 2011 | 3.828027 |
| 2012 | 4.013289 |
| 2013 | 5.533394 |
| 2014 | 4.955227 |
| 2015 | 3.095624 |
| 2016 | 3.701364 |
| 2017 | 4.281412 |
| 2018 | 4.816374 |
| 2019 | 3.381877 |
| 2020 | 5.150290 |
| 2022 | 4.763420 |
ggplot(spring_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average spring temperatures for water years 2005-2021
spring_sd_mk_457 <- mk.test(spring_standard_dev_all_457$sd_2)
print(spring_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_457$sd_2
## z = -0.40791, n = 31, p-value = 0.6833
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -25.00000000 3461.66666667 -0.05376344
spring_sd_sens_457 <- sens.slope(spring_standard_dev_all_457$sd_2)
print(spring_sd_sens_457)
##
## Sen's slope
##
## data: spring_standard_dev_all_457$sd_2
## z = -0.40791, n = 31, p-value = 0.6833
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04050466 0.02341679
## sample estimates:
## Sen's slope
## -0.009047087
Fall
fall_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_457 <- fall_standard_dev_all_457 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.400661 |
| 1988 | 4.584406 |
| 1989 | 3.996961 |
| 1990 | 6.250106 |
| 1991 | 5.047580 |
| 1992 | 5.467105 |
| 1993 | 8.068974 |
| 1995 | 5.290657 |
| 1998 | 6.314970 |
| 1999 | 3.940660 |
| 2000 | 5.157230 |
| 2001 | 4.919721 |
| 2002 | 4.734059 |
| 2004 | 4.141194 |
| 2005 | 4.358883 |
| 2006 | 4.004181 |
| 2007 | 5.438213 |
| 2008 | 4.035213 |
| 2009 | 4.982771 |
| 2010 | 5.937461 |
| 2011 | 4.537316 |
| 2012 | 5.087419 |
| 2013 | 5.480590 |
| 2014 | 5.512525 |
| 2015 | 4.038445 |
| 2016 | 3.996749 |
| 2017 | 4.472564 |
| 2018 | 5.468127 |
| 2019 | 5.463964 |
| 2020 | 7.934484 |
| 2022 | 5.247157 |
ggplot(fall_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_457 <- mk.test(fall_standard_dev_all_457$sd_2)
print(fall_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_457$sd_2
## z = 0.4759, n = 31, p-value = 0.6341
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.900000e+01 3.461667e+03 6.236559e-02
fall_sd_sens_457 <- sens.slope(fall_standard_dev_all_457$sd_2)
print(fall_sd_sens_457)
##
## Sen's slope
##
## data: fall_standard_dev_all_457$sd_2
## z = 0.4759, n = 31, p-value = 0.6341
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03144568 0.04218719
## sample estimates:
## Sen's slope
## 0.006519015
Spring
spring_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_457_ad <- spring_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.331239 |
| 1988 | 4.807664 |
| 1989 | 4.183754 |
| 1990 | 3.370922 |
| 1991 | 4.951458 |
| 1992 | 3.327405 |
| 1993 | 4.172737 |
| 1995 | 2.982327 |
| 1998 | 3.977982 |
| 1999 | 4.882915 |
| 2000 | 4.546692 |
| 2001 | 3.976395 |
| 2002 | 3.836939 |
| 2004 | 3.883829 |
| 2005 | 4.121145 |
| 2006 | 4.034492 |
| 2007 | 4.413686 |
| 2008 | 4.945922 |
| 2009 | 4.693765 |
| 2010 | 4.714359 |
| 2011 | 3.828027 |
| 2012 | 4.013289 |
| 2013 | 5.533394 |
| 2014 | 4.955227 |
| 2015 | 3.095624 |
| 2016 | 3.701364 |
| 2017 | 4.281412 |
| 2018 | 4.816374 |
| 2019 | 3.381877 |
| 2020 | 5.150290 |
| 2022 | 4.763420 |
ggplot(spring_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average spring temperatures for water years 1986-2021
spring_sd_mk_457_ad <- mk.test(spring_standard_dev_all_457_ad$sd_2)
print(spring_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_457_ad$sd_2
## z = 0.81583, n = 31, p-value = 0.4146
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 49.0000000 3461.6666667 0.1053763
spring_sd_sens_457_ad <- sens.slope(spring_standard_dev_all_457_ad$sd_2)
print(spring_sd_sens_457_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_457_ad$sd_2
## z = 0.81583, n = 31, p-value = 0.4146
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01627168 0.04412589
## sample estimates:
## Sen's slope
## 0.01336879
Fall
fall_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_457_ad <- fall_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.990231 |
| 1988 | 4.137868 |
| 1989 | 3.600006 |
| 1990 | 5.671249 |
| 1991 | 4.582113 |
| 1992 | 5.034852 |
| 1993 | 7.541701 |
| 1995 | 4.796039 |
| 1998 | 5.745489 |
| 1999 | 3.590034 |
| 2000 | 4.689954 |
| 2001 | 4.446426 |
| 2002 | 4.298527 |
| 2004 | 4.139723 |
| 2005 | 4.357415 |
| 2006 | 4.004072 |
| 2007 | 5.438310 |
| 2008 | 4.036238 |
| 2009 | 4.982748 |
| 2010 | 5.936533 |
| 2011 | 4.538512 |
| 2012 | 5.087680 |
| 2013 | 5.477447 |
| 2014 | 5.512148 |
| 2015 | 4.037808 |
| 2016 | 3.996309 |
| 2017 | 4.469116 |
| 2018 | 5.466855 |
| 2019 | 5.464300 |
| 2020 | 7.934659 |
| 2022 | 5.247520 |
ggplot(fall_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_457_ad <- mk.test(fall_standard_dev_all_457_ad$sd_2)
print(fall_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_457_ad$sd_2
## z = 1.4617, n = 31, p-value = 0.1438
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 87.0000000 3461.6666667 0.1870968
fall_sd_sens_457_ad <- sens.slope(fall_standard_dev_all_457_ad$sd_2)
print(fall_sd_sens_457_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_457_ad$sd_2
## z = 1.4617, n = 31, p-value = 0.1438
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.008516449 0.063195741
## sample estimates:
## Sen's slope
## 0.02622744
Oyler -> Morrisey 8/7/2006
snotel_467 <- SNOTEL_yampa_area %>%
filter(site_id == "467")
#str(snotel_467) # check the date, usually a character.
snotel_467$Date <- as.Date(snotel_467$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_467_clean <- snotel_467 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_467_clean <- snotel_467_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_467_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_467_clean <- snotel_467_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_467_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_467_cull_count <- snotel_467_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_467_cull_count
# filtering for too few observations in a year
snotel_467_cull_count_days <- snotel_467_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_467_cull_count_days
## # A tibble: 6 x 2
## # Groups: waterYear [6]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1994 326
## 3 1998 342
## 4 1999 281
## 5 2001 339
## 6 2021 344
snotel_467_clean_culled <- snotel_467_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1994" & waterYear != "1998" & waterYear != "1999" & waterYear != "2001" & waterYear != "2021")# & waterYear != "2021")# & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_467_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Also 1986
ggplot(snotel_467_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_467_xts <- xts(snotel_467_clean_culled$temperature_mean, order.by = snotel_467_clean_culled$Date)
dygraph(temp_467_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_467_clean_culled <- snotel_467_clean_culled %>%
# filter(temperature_mean > -30)
#temp_467_xts <- xts(snotel_467_clean_culled$temperature_mean, order.by = snotel_467_clean_culled$Date)
#dygraph(temp_467_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_467_adjusted <- snotel_467_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-08-07", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_467 <- snotel_467_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_467 <- yearly_wy_aver_467 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_467 <- daily_wy_aver_467 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_467$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_467 <-daily_wy_aver_467 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_467$date_temp <- signif(daily_wy_aver2_467$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_467, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_467 <- daily_wy_aver_467 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_467 <- standard_dev_467 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_467 <- standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 9.103406 |
| 1988 | 10.510726 |
| 1989 | 10.049523 |
| 1990 | 9.547427 |
| 1991 | 9.692602 |
| 1992 | 8.717383 |
| 1993 | 9.114798 |
| 1995 | 8.625842 |
| 1996 | 8.985964 |
| 1997 | 9.119643 |
| 2000 | 8.850761 |
| 2002 | 10.120172 |
| 2003 | 9.161089 |
| 2004 | 8.589463 |
| 2005 | 8.525521 |
| 2006 | 9.564659 |
| 2007 | 9.088368 |
| 2008 | 9.090316 |
| 2009 | 8.102303 |
| 2010 | 8.886760 |
| 2011 | 8.734057 |
| 2012 | 8.902720 |
| 2013 | 9.375328 |
| 2014 | 8.477094 |
| 2015 | 8.044768 |
| 2016 | 8.660871 |
| 2017 | 8.514442 |
| 2018 | 8.465435 |
| 2019 | 8.883368 |
| 2020 | 9.345838 |
| 2022 | 8.902383 |
ggplot(standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average temperatures for water years 2005-2021
sd_mk_467 <- mk.test(standard_dev_all_467$sd_2)
print(sd_mk_467)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_467$sd_2
## z = -2.7194, n = 31, p-value = 0.00654
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -161.0000000 3461.6666667 -0.3462366
sd_sens_467 <- sens.slope(standard_dev_all_467$sd_2)
print(sd_sens_467)
##
## Sen's slope
##
## data: standard_dev_all_467$sd_2
## z = -2.7194, n = 31, p-value = 0.00654
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.053188331 -0.007753413
## sample estimates:
## Sen's slope
## -0.02739628
#using the clean culled df:
#average water year temperature
yearly_wy_aver_467_ad <- snotel_467_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_467_ad <- yearly_wy_aver_467_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_467_ad <- daily_wy_aver_467_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_467_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_467_ad <-daily_wy_aver_467_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_467_ad$date_temp_ad <- signif(daily_wy_aver2_467_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_467_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_467_ad <- daily_wy_aver_467_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_467_ad <- standard_dev_467_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_467_ad <- standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.416565 |
| 1988 | 9.721370 |
| 1989 | 9.348058 |
| 1990 | 8.816292 |
| 1991 | 9.016762 |
| 1992 | 8.057564 |
| 1993 | 8.438420 |
| 1995 | 7.963510 |
| 1996 | 8.304891 |
| 1997 | 8.454695 |
| 2000 | 8.126220 |
| 2002 | 9.357756 |
| 2003 | 8.423881 |
| 2004 | 7.952025 |
| 2005 | 7.847462 |
| 2006 | 8.843490 |
| 2007 | 9.088080 |
| 2008 | 9.090597 |
| 2009 | 8.102286 |
| 2010 | 8.886876 |
| 2011 | 8.734381 |
| 2012 | 8.902800 |
| 2013 | 9.375482 |
| 2014 | 8.477382 |
| 2015 | 8.045353 |
| 2016 | 8.661195 |
| 2017 | 8.514535 |
| 2018 | 8.465471 |
| 2019 | 8.883707 |
| 2020 | 9.345830 |
| 2022 | 8.902408 |
ggplot(standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average temperatures for water years 1986-2021
sd_mk_467_ad <- mk.test(standard_dev_all_467_ad$sd_2)
print(sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_467_ad$sd_2
## z = 0.57788, n = 31, p-value = 0.5633
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.500000e+01 3.461667e+03 7.526882e-02
sd_sens_467_ad <- sens.slope(standard_dev_all_467_ad$sd_2)
print(sd_sens_467_ad)
##
## Sen's slope
##
## data: standard_dev_all_467_ad$sd_2
## z = 0.57788, n = 31, p-value = 0.5633
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01785969 0.02658485
## sample estimates:
## Sen's slope
## 0.003440178
summer_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_467 <- summer_standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.107235 |
| 1988 | 3.582410 |
| 1989 | 4.395147 |
| 1990 | 3.912715 |
| 1991 | 2.948044 |
| 1992 | 3.601909 |
| 1993 | 4.388592 |
| 1995 | 3.927602 |
| 1996 | 2.480453 |
| 1997 | 2.719147 |
| 2000 | 3.323566 |
| 2002 | 3.319019 |
| 2003 | 4.368058 |
| 2004 | 3.296036 |
| 2005 | 4.449789 |
| 2006 | 3.043424 |
| 2007 | 3.237666 |
| 2008 | 3.817618 |
| 2009 | 3.399101 |
| 2010 | 2.939544 |
| 2011 | 2.765137 |
| 2012 | 2.513370 |
| 2013 | 2.547579 |
| 2014 | 3.088134 |
| 2015 | 2.409296 |
| 2016 | 2.337193 |
| 2017 | 2.455106 |
| 2018 | 2.812467 |
| 2019 | 3.433491 |
| 2020 | 3.207797 |
| 2022 | 2.895664 |
ggplot(summer_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average summer temperatures for water years 2005-2021
summer_sd_mk_467 <- mk.test(summer_standard_dev_all_467$sd_2)
print(summer_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_467$sd_2
## z = -2.7874, n = 31, p-value = 0.005313
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -165.0000000 3461.6666667 -0.3548387
summer_sd_sens_467 <- sens.slope(summer_standard_dev_all_467$sd_2)
print(summer_sd_sens_467)
##
## Sen's slope
##
## data: summer_standard_dev_all_467$sd_2
## z = -2.7874, n = 31, p-value = 0.005313
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.06220532 -0.01078288
## sample estimates:
## Sen's slope
## -0.03424091
Winter
winter_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_467 <- winter_standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.822667 |
| 1988 | 5.465569 |
| 1989 | 6.408452 |
| 1990 | 5.254698 |
| 1991 | 5.955963 |
| 1992 | 4.589232 |
| 1993 | 4.805375 |
| 1995 | 5.027672 |
| 1996 | 5.311224 |
| 1997 | 5.538537 |
| 2000 | 5.145188 |
| 2002 | 5.813128 |
| 2003 | 4.413741 |
| 2004 | 5.445695 |
| 2005 | 4.325787 |
| 2006 | 5.538987 |
| 2007 | 5.869957 |
| 2008 | 5.481150 |
| 2009 | 5.066819 |
| 2010 | 5.132450 |
| 2011 | 5.371335 |
| 2012 | 4.991392 |
| 2013 | 5.971719 |
| 2014 | 4.829881 |
| 2015 | 5.490580 |
| 2016 | 4.885477 |
| 2017 | 6.296067 |
| 2018 | 4.688348 |
| 2019 | 4.447987 |
| 2020 | 4.842838 |
| 2022 | 5.512484 |
ggplot(winter_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average winter temperatures for water years 2005-2021
winter_sd_mk_467 <- mk.test(winter_standard_dev_all_467$sd_2)
print(winter_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_467$sd_2
## z = -0.44191, n = 31, p-value = 0.6586
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -27.00000000 3461.66666667 -0.05806452
winter_sd_sens_467 <- sens.slope(winter_standard_dev_all_467$sd_2)
print(winter_sd_sens_467)
##
## Sen's slope
##
## data: winter_standard_dev_all_467$sd_2
## z = -0.44191, n = 31, p-value = 0.6586
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03226844 0.01696040
## sample estimates:
## Sen's slope
## -0.007167169
Summer
summer_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_467_ad <- summer_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.784489 |
| 1988 | 3.226085 |
| 1989 | 3.944095 |
| 1990 | 3.517632 |
| 1991 | 2.642143 |
| 1992 | 3.232310 |
| 1993 | 3.957160 |
| 1995 | 3.525595 |
| 1996 | 2.221097 |
| 1997 | 2.434890 |
| 2000 | 2.978025 |
| 2002 | 2.974593 |
| 2003 | 3.915832 |
| 2004 | 2.955027 |
| 2005 | 3.998585 |
| 2006 | 2.799926 |
| 2007 | 3.237536 |
| 2008 | 3.817084 |
| 2009 | 3.398446 |
| 2010 | 2.938625 |
| 2011 | 2.764731 |
| 2012 | 2.513117 |
| 2013 | 2.547020 |
| 2014 | 3.087993 |
| 2015 | 2.409236 |
| 2016 | 2.337513 |
| 2017 | 2.454951 |
| 2018 | 2.811770 |
| 2019 | 3.432939 |
| 2020 | 3.207927 |
| 2022 | 2.895116 |
ggplot(summer_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average summer temperatures for water years 1986-2021
summer_sd_mk_467_ad <- mk.test(summer_standard_dev_all_467_ad$sd_2)
print(summer_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_467_ad$sd_2
## z = -1.5637, n = 31, p-value = 0.1179
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -93.000 3461.667 -0.200
summer_sd_sens_467_ad <- sens.slope(summer_standard_dev_all_467_ad$sd_2)
print(summer_sd_sens_467_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_467_ad$sd_2
## z = -1.5637, n = 31, p-value = 0.1179
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.040766760 0.004540866
## sample estimates:
## Sen's slope
## -0.01597
Winter
winter_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_467_ad <- winter_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.637285 |
| 1988 | 5.263502 |
| 1989 | 6.205400 |
| 1990 | 5.039930 |
| 1991 | 5.822011 |
| 1992 | 4.406849 |
| 1993 | 4.624011 |
| 1995 | 4.798378 |
| 1996 | 5.098253 |
| 1997 | 5.312870 |
| 2000 | 4.858449 |
| 2002 | 5.574486 |
| 2003 | 4.225215 |
| 2004 | 5.198877 |
| 2005 | 4.150964 |
| 2006 | 5.323927 |
| 2007 | 5.870345 |
| 2008 | 5.481471 |
| 2009 | 5.066553 |
| 2010 | 5.132290 |
| 2011 | 5.371863 |
| 2012 | 4.991486 |
| 2013 | 5.971969 |
| 2014 | 4.830528 |
| 2015 | 5.490657 |
| 2016 | 4.885616 |
| 2017 | 6.296150 |
| 2018 | 4.688606 |
| 2019 | 4.448957 |
| 2020 | 4.842558 |
| 2022 | 5.512316 |
ggplot(winter_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average winter temperatures for water years 1986-2021
winter_sd_mk_467_ad <- mk.test(winter_standard_dev_all_467_ad$sd_2)
print(winter_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_467_ad$sd_2
## z = 0.40791, n = 31, p-value = 0.6833
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.500000e+01 3.461667e+03 5.376344e-02
winter_sd_sens_467_ad <- sens.slope(winter_standard_dev_all_467_ad$sd_2)
print(winter_sd_sens_467_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_467_ad$sd_2
## z = 0.40791, n = 31, p-value = 0.6833
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02475301 0.02754414
## sample estimates:
## Sen's slope
## 0.003609928
spring_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_467 <- spring_standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.759311 |
| 1988 | 5.677907 |
| 1989 | 5.538059 |
| 1990 | 4.423615 |
| 1991 | 5.841909 |
| 1992 | 4.206389 |
| 1993 | 5.031550 |
| 1995 | 3.368056 |
| 1996 | 4.923826 |
| 1997 | 5.907550 |
| 2000 | 5.554563 |
| 2002 | 4.638264 |
| 2003 | 5.714145 |
| 2004 | 4.502781 |
| 2005 | 4.698876 |
| 2006 | 4.736049 |
| 2007 | 4.675450 |
| 2008 | 5.238475 |
| 2009 | 4.938268 |
| 2010 | 4.821432 |
| 2011 | 4.019872 |
| 2012 | 4.353063 |
| 2013 | 5.940107 |
| 2014 | 5.431920 |
| 2015 | 3.199916 |
| 2016 | 4.018451 |
| 2017 | 4.585979 |
| 2018 | 4.906599 |
| 2019 | 3.711326 |
| 2020 | 5.456281 |
| 2022 | 5.163975 |
ggplot(spring_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average spring temperatures for water years 2005-2021
spring_sd_mk_467 <- mk.test(spring_standard_dev_all_467$sd_2)
print(spring_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_467$sd_2
## z = -1.0198, n = 31, p-value = 0.3078
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -61.0000000 3461.6666667 -0.1311828
spring_sd_sens_467 <- sens.slope(spring_standard_dev_all_467$sd_2)
print(spring_sd_sens_467)
##
## Sen's slope
##
## data: spring_standard_dev_all_467$sd_2
## z = -1.0198, n = 31, p-value = 0.3078
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05325736 0.01846657
## sample estimates:
## Sen's slope
## -0.01542513
Fall
fall_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_467 <- fall_standard_dev_all_467 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.753234 |
| 1988 | 4.851201 |
| 1989 | 3.607670 |
| 1990 | 6.499477 |
| 1991 | 5.164760 |
| 1992 | 6.175766 |
| 1993 | 4.477016 |
| 1995 | 6.517719 |
| 1996 | 5.655165 |
| 1997 | 6.483114 |
| 2000 | 5.350755 |
| 2002 | 5.034039 |
| 2003 | 5.025969 |
| 2004 | 4.531563 |
| 2005 | 5.039952 |
| 2006 | 4.699426 |
| 2007 | 5.636914 |
| 2008 | 4.152343 |
| 2009 | 5.108373 |
| 2010 | 6.736406 |
| 2011 | 4.709851 |
| 2012 | 5.198303 |
| 2013 | 5.459740 |
| 2014 | 5.699981 |
| 2015 | 4.261994 |
| 2016 | 4.083426 |
| 2017 | 4.875346 |
| 2018 | 5.932391 |
| 2019 | 5.854839 |
| 2020 | 8.458318 |
| 2022 | 5.912439 |
ggplot(fall_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_467 <- mk.test(fall_standard_dev_all_467$sd_2)
print(fall_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_467$sd_2
## z = 0.81583, n = 31, p-value = 0.4146
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 49.0000000 3461.6666667 0.1053763
fall_sd_sens_467 <- sens.slope(fall_standard_dev_all_467$sd_2)
print(fall_sd_sens_467)
##
## Sen's slope
##
## data: fall_standard_dev_all_467$sd_2
## z = 0.81583, n = 31, p-value = 0.4146
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02643250 0.05247357
## sample estimates:
## Sen's slope
## 0.01663107
Spring
spring_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_467_ad <- spring_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.345261 |
| 1988 | 5.189993 |
| 1989 | 5.064416 |
| 1990 | 4.053481 |
| 1991 | 5.369982 |
| 1992 | 3.817573 |
| 1993 | 4.597528 |
| 1995 | 3.110326 |
| 1996 | 4.513830 |
| 1997 | 5.493105 |
| 2000 | 5.058377 |
| 2002 | 4.205962 |
| 2003 | 5.216521 |
| 2004 | 4.099129 |
| 2005 | 4.282753 |
| 2006 | 4.306916 |
| 2007 | 4.675450 |
| 2008 | 5.238475 |
| 2009 | 4.938268 |
| 2010 | 4.821432 |
| 2011 | 4.019872 |
| 2012 | 4.353063 |
| 2013 | 5.940107 |
| 2014 | 5.431920 |
| 2015 | 3.199916 |
| 2016 | 4.018451 |
| 2017 | 4.585979 |
| 2018 | 4.906599 |
| 2019 | 3.711326 |
| 2020 | 5.456281 |
| 2022 | 5.163975 |
ggplot(spring_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average spring temperatures for water years 1986-2021
spring_sd_mk_467_ad <- mk.test(spring_standard_dev_all_467_ad$sd_2)
print(spring_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_467_ad$sd_2
## z = 0.27194, n = 31, p-value = 0.7857
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.700000e+01 3.461667e+03 3.655914e-02
spring_sd_sens_467_ad <- sens.slope(spring_standard_dev_all_467_ad$sd_2)
print(spring_sd_sens_467_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_467_ad$sd_2
## z = 0.27194, n = 31, p-value = 0.7857
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02909624 0.03438479
## sample estimates:
## Sen's slope
## 0.004390786
Fall
fall_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_467_ad <- fall_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.321501 |
| 1988 | 4.385649 |
| 1989 | 3.249152 |
| 1990 | 5.916589 |
| 1991 | 4.701663 |
| 1992 | 5.703446 |
| 1993 | 4.060391 |
| 1995 | 5.984452 |
| 1996 | 5.159211 |
| 1997 | 5.950139 |
| 2000 | 4.860667 |
| 2002 | 4.573494 |
| 2003 | 4.582872 |
| 2004 | 4.107656 |
| 2005 | 4.582222 |
| 2006 | 4.350618 |
| 2007 | 5.630627 |
| 2008 | 4.149337 |
| 2009 | 5.104981 |
| 2010 | 6.735458 |
| 2011 | 4.706827 |
| 2012 | 5.196105 |
| 2013 | 5.457329 |
| 2014 | 5.698135 |
| 2015 | 4.262668 |
| 2016 | 4.079319 |
| 2017 | 4.872397 |
| 2018 | 5.929876 |
| 2019 | 5.853024 |
| 2020 | 8.457092 |
| 2022 | 5.909628 |
ggplot(fall_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_467_ad <- mk.test(fall_standard_dev_all_467_ad$sd_2)
print(fall_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_467_ad$sd_2
## z = 1.7676, n = 31, p-value = 0.07712
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 105.0000000 3461.6666667 0.2258065
fall_sd_sens_467_ad <- sens.slope(fall_standard_dev_all_467_ad$sd_2)
print(fall_sd_sens_467_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_467_ad$sd_2
## z = 1.7676, n = 31, p-value = 0.07712
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.002361453 0.077051557
## sample estimates:
## Sen's slope
## 0.03410986
Morrisey 5/22/2006
snotel_607 <- SNOTEL_yampa_area %>%
filter(site_id == "607")
#str(snotel_607) # check the date, usually a character.
snotel_607$Date <- as.Date(snotel_607$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_607_clean <- snotel_607 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_607_clean <- snotel_607_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_607_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_607_clean <- snotel_607_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_607_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_607_cull_count <- snotel_607_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_607_cull_count
# filtering for too few observations in a year
snotel_607_cull_count_days <- snotel_607_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_607_cull_count_days
## # A tibble: 4 x 2
## # Groups: waterYear [4]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1994 333
## 3 2019 284
## 4 2020 328
snotel_607_clean_culled <- snotel_607_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1994" & waterYear != "2019" & waterYear != "2020")# & waterYear != "2001" & waterYear != "2021")# & waterYear != "2021")# & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_607_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Also 1986
ggplot(snotel_607_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_607_xts <- xts(snotel_607_clean_culled$temperature_mean, order.by = snotel_607_clean_culled$Date)
dygraph(temp_607_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_607_clean_culled <- snotel_607_clean_culled %>%
# filter(temperature_mean > -30)
#temp_607_xts <- xts(snotel_607_clean_culled$temperature_mean, order.by = snotel_607_clean_culled$Date)
#dygraph(temp_607_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_607_adjusted <- snotel_607_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-05-22", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_607 <- snotel_607_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_607 <- yearly_wy_aver_607 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_607 <- daily_wy_aver_607 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_607$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_607 <-daily_wy_aver_607 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_607$date_temp <- signif(daily_wy_aver2_607$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_607, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_607 <- daily_wy_aver_607 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_607 <- standard_dev_607 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_607 <- standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.658921 |
| 1988 | 9.691007 |
| 1989 | 9.677093 |
| 1990 | 9.127534 |
| 1991 | 9.267600 |
| 1992 | 8.495617 |
| 1993 | 8.542784 |
| 1995 | 8.427463 |
| 1996 | 8.936524 |
| 1997 | 8.897439 |
| 1998 | 9.097517 |
| 1999 | 8.407095 |
| 2000 | 8.685669 |
| 2001 | 9.559462 |
| 2002 | 10.100422 |
| 2003 | 8.935295 |
| 2004 | 8.581025 |
| 2005 | 8.571462 |
| 2006 | 9.563477 |
| 2007 | 9.027055 |
| 2008 | 8.751128 |
| 2009 | 7.935985 |
| 2010 | 9.022507 |
| 2011 | 8.612122 |
| 2012 | 8.812590 |
| 2013 | 9.410619 |
| 2014 | 8.353556 |
| 2015 | 7.907493 |
| 2016 | 8.522596 |
| 2017 | 8.366193 |
| 2018 | 8.240463 |
| 2021 | 8.972977 |
| 2022 | 8.767136 |
ggplot(standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average temperatures for water years 2005-2021
sd_mk_607 <- mk.test(standard_dev_all_607$sd_2)
print(sd_mk_607)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_607$sd_2
## z = -2.0298, n = 33, p-value = 0.04238
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -132.000 4165.333 -0.250
sd_sens_607 <- sens.slope(standard_dev_all_607$sd_2)
print(sd_sens_607)
##
## Sen's slope
##
## data: standard_dev_all_607$sd_2
## z = -2.0298, n = 33, p-value = 0.04238
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.036056261 -0.001515865
## sample estimates:
## Sen's slope
## -0.01788946
#using the clean culled df:
#average water year temperature
yearly_wy_aver_607_ad <- snotel_607_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_607_ad <- yearly_wy_aver_607_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_607_ad <- daily_wy_aver_607_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_607_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_607_ad <-daily_wy_aver_607_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_607_ad$date_temp_ad <- signif(daily_wy_aver2_607_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_607_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_607_ad <- daily_wy_aver_607_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_607_ad <- standard_dev_607_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_607_ad <- standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.065805 |
| 1988 | 9.041423 |
| 1989 | 9.118850 |
| 1990 | 8.514101 |
| 1991 | 8.699806 |
| 1992 | 7.927056 |
| 1993 | 7.982533 |
| 1995 | 7.846909 |
| 1996 | 8.320426 |
| 1997 | 8.291259 |
| 1998 | 8.445612 |
| 1999 | 7.829298 |
| 2000 | 8.031514 |
| 2001 | 8.877490 |
| 2002 | 9.409575 |
| 2003 | 8.273822 |
| 2004 | 8.002022 |
| 2005 | 7.966244 |
| 2006 | 8.852307 |
| 2007 | 9.027252 |
| 2008 | 8.750916 |
| 2009 | 7.936108 |
| 2010 | 9.022503 |
| 2011 | 8.612197 |
| 2012 | 8.812993 |
| 2013 | 9.410822 |
| 2014 | 8.353805 |
| 2015 | 7.907862 |
| 2016 | 8.523025 |
| 2017 | 8.366000 |
| 2018 | 8.241006 |
| 2021 | 8.973005 |
| 2022 | 8.767834 |
ggplot(standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average temperatures for water years 1986-2021
sd_mk_607_ad <- mk.test(standard_dev_all_607_ad$sd_2)
print(sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_607_ad$sd_2
## z = 0.63527, n = 33, p-value = 0.5253
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 4.200000e+01 4.165333e+03 7.954545e-02
sd_sens_607_ad <- sens.slope(standard_dev_all_607_ad$sd_2)
print(sd_sens_607_ad)
##
## Sen's slope
##
## data: standard_dev_all_607_ad$sd_2
## z = 0.63527, n = 33, p-value = 0.5253
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.008825448 0.026678756
## sample estimates:
## Sen's slope
## 0.006477733
summer_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_607 <- summer_standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.583588 |
| 1988 | 2.565242 |
| 1989 | 3.620794 |
| 1990 | 2.612922 |
| 1991 | 2.236880 |
| 1992 | 3.025923 |
| 1993 | 3.299556 |
| 1995 | 3.283857 |
| 1996 | 2.032202 |
| 1997 | 2.168654 |
| 1998 | 3.534476 |
| 1999 | 2.587835 |
| 2000 | 2.452299 |
| 2001 | 3.022235 |
| 2002 | 2.737153 |
| 2003 | 3.344690 |
| 2004 | 2.787832 |
| 2005 | 3.509173 |
| 2006 | 2.377869 |
| 2007 | 2.609517 |
| 2008 | 2.850011 |
| 2009 | 2.461621 |
| 2010 | 2.444383 |
| 2011 | 2.015050 |
| 2012 | 2.110717 |
| 2013 | 2.092884 |
| 2014 | 2.290323 |
| 2015 | 1.993793 |
| 2016 | 2.061230 |
| 2017 | 2.066564 |
| 2018 | 2.221880 |
| 2021 | 2.452833 |
| 2022 | 2.321945 |
ggplot(summer_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average summer temperatures for water years 2005-2021
summer_sd_mk_607 <- mk.test(summer_standard_dev_all_607$sd_2)
print(summer_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_607$sd_2
## z = -2.8665, n = 33, p-value = 0.004151
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -186.0000000 4165.3333333 -0.3522727
summer_sd_sens_607 <- sens.slope(summer_standard_dev_all_607$sd_2)
print(summer_sd_sens_607)
##
## Sen's slope
##
## data: summer_standard_dev_all_607$sd_2
## z = -2.8665, n = 33, p-value = 0.004151
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.044705924 -0.007441373
## sample estimates:
## Sen's slope
## -0.0225118
Winter
winter_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_607 <- winter_standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.609281 |
| 1988 | 5.396847 |
| 1989 | 6.884075 |
| 1990 | 5.598987 |
| 1991 | 5.851415 |
| 1992 | 4.690408 |
| 1993 | 4.894448 |
| 1995 | 5.368485 |
| 1996 | 5.289318 |
| 1997 | 5.245294 |
| 1998 | 4.671769 |
| 1999 | 5.372814 |
| 2000 | 4.665543 |
| 2001 | 4.387652 |
| 2002 | 5.810274 |
| 2003 | 4.545356 |
| 2004 | 5.462611 |
| 2005 | 4.756776 |
| 2006 | 5.387372 |
| 2007 | 5.926304 |
| 2008 | 5.267534 |
| 2009 | 4.843660 |
| 2010 | 5.181054 |
| 2011 | 5.492808 |
| 2012 | 4.915640 |
| 2013 | 6.026673 |
| 2014 | 4.693553 |
| 2015 | 5.096193 |
| 2016 | 5.011483 |
| 2017 | 6.320428 |
| 2018 | 4.771497 |
| 2021 | 4.533264 |
| 2022 | 5.616885 |
ggplot(winter_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average winter temperatures for water years 2005-2021
winter_sd_mk_607 <- mk.test(winter_standard_dev_all_607$sd_2)
print(winter_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_607$sd_2
## z = -0.20143, n = 33, p-value = 0.8404
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -14.00000000 4165.33333333 -0.02651515
winter_sd_sens_607 <- sens.slope(winter_standard_dev_all_607$sd_2)
print(winter_sd_sens_607)
##
## Sen's slope
##
## data: winter_standard_dev_all_607$sd_2
## z = -0.20143, n = 33, p-value = 0.8404
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02826186 0.01795937
## sample estimates:
## Sen's slope
## -0.003469017
Summer
summer_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_607_ad <- summer_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.318805 |
| 1988 | 2.306293 |
| 1989 | 3.254289 |
| 1990 | 2.344330 |
| 1991 | 2.007497 |
| 1992 | 2.724830 |
| 1993 | 2.973794 |
| 1995 | 2.948387 |
| 1996 | 1.821227 |
| 1997 | 1.942714 |
| 1998 | 3.177168 |
| 1999 | 2.322150 |
| 2000 | 2.195582 |
| 2001 | 2.719956 |
| 2002 | 2.450618 |
| 2003 | 2.997050 |
| 2004 | 2.501366 |
| 2005 | 3.154247 |
| 2006 | 2.377115 |
| 2007 | 2.609739 |
| 2008 | 2.849149 |
| 2009 | 2.460153 |
| 2010 | 2.443292 |
| 2011 | 2.014225 |
| 2012 | 2.110905 |
| 2013 | 2.092375 |
| 2014 | 2.290898 |
| 2015 | 1.993906 |
| 2016 | 2.060732 |
| 2017 | 2.065392 |
| 2018 | 2.221542 |
| 2021 | 2.451986 |
| 2022 | 2.322366 |
ggplot(summer_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average summer temperatures for water years 1986-2021
summer_sd_mk_607_ad <- mk.test(summer_standard_dev_all_607_ad$sd_2)
print(summer_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_607_ad$sd_2
## z = -1.472, n = 33, p-value = 0.141
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -96.0000000 4165.3333333 -0.1818182
summer_sd_sens_607_ad <- sens.slope(summer_standard_dev_all_607_ad$sd_2)
print(summer_sd_sens_607_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_607_ad$sd_2
## z = -1.472, n = 33, p-value = 0.141
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.030740478 0.003239472
## sample estimates:
## Sen's slope
## -0.0112657
Winter
winter_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_607_ad <- winter_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.468607 |
| 1988 | 5.245841 |
| 1989 | 6.788552 |
| 1990 | 5.453244 |
| 1991 | 5.773579 |
| 1992 | 4.543015 |
| 1993 | 4.751710 |
| 1995 | 5.187761 |
| 1996 | 5.129553 |
| 1997 | 5.076784 |
| 1998 | 4.506274 |
| 1999 | 5.210104 |
| 2000 | 4.487469 |
| 2001 | 4.251440 |
| 2002 | 5.629664 |
| 2003 | 4.383574 |
| 2004 | 5.261604 |
| 2005 | 4.624994 |
| 2006 | 5.213672 |
| 2007 | 5.926599 |
| 2008 | 5.266889 |
| 2009 | 4.844312 |
| 2010 | 5.180838 |
| 2011 | 5.492143 |
| 2012 | 4.915451 |
| 2013 | 6.027192 |
| 2014 | 4.693837 |
| 2015 | 5.095752 |
| 2016 | 5.011382 |
| 2017 | 6.319899 |
| 2018 | 4.771653 |
| 2021 | 4.533133 |
| 2022 | 5.617564 |
ggplot(winter_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average winter temperatures for water years 1986-2021
winter_sd_mk_607_ad <- mk.test(winter_standard_dev_all_607_ad$sd_2)
print(winter_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_607_ad$sd_2
## z = 0.29439, n = 33, p-value = 0.7685
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.000000e+01 4.165333e+03 3.787879e-02
winter_sd_sens_607_ad <- sens.slope(winter_standard_dev_all_607_ad$sd_2)
print(winter_sd_sens_607_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_607_ad$sd_2
## z = 0.29439, n = 33, p-value = 0.7685
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01937265 0.02512440
## sample estimates:
## Sen's slope
## 0.002218487
spring_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_607 <- spring_standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.128704 |
| 1988 | 4.828032 |
| 1989 | 4.793939 |
| 1990 | 3.617680 |
| 1991 | 5.101939 |
| 1992 | 3.548957 |
| 1993 | 4.134003 |
| 1995 | 3.137571 |
| 1996 | 4.750844 |
| 1997 | 5.477828 |
| 1998 | 4.461680 |
| 1999 | 5.217342 |
| 2000 | 5.279247 |
| 2001 | 4.271508 |
| 2002 | 3.658021 |
| 2003 | 5.174149 |
| 2004 | 4.110870 |
| 2005 | 4.370785 |
| 2006 | 3.955005 |
| 2007 | 4.116424 |
| 2008 | 4.982486 |
| 2009 | 4.871936 |
| 2010 | 4.645793 |
| 2011 | 3.829609 |
| 2012 | 3.647185 |
| 2013 | 5.316719 |
| 2014 | 5.007019 |
| 2015 | 2.886453 |
| 2016 | 3.661469 |
| 2017 | 4.108609 |
| 2018 | 4.401375 |
| 2021 | 4.205541 |
| 2022 | 4.824438 |
ggplot(spring_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average spring temperatures for water years 2005-2021
spring_sd_mk_607 <- mk.test(spring_standard_dev_all_607$sd_2)
print(spring_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_607$sd_2
## z = -0.38736, n = 33, p-value = 0.6985
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -26.00000000 4165.33333333 -0.04924242
spring_sd_sens_607 <- sens.slope(spring_standard_dev_all_607$sd_2)
print(spring_sd_sens_607)
##
## Sen's slope
##
## data: spring_standard_dev_all_607$sd_2
## z = -0.38736, n = 33, p-value = 0.6985
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03709515 0.02099501
## sample estimates:
## Sen's slope
## -0.004316265
Fall
fall_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_607 <- fall_standard_dev_all_607 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.183927 |
| 1988 | 4.067441 |
| 1989 | 3.972759 |
| 1990 | 5.782180 |
| 1991 | 4.579731 |
| 1992 | 5.436559 |
| 1993 | 3.462890 |
| 1995 | 4.984161 |
| 1996 | 5.103687 |
| 1997 | 6.175202 |
| 1998 | 6.205987 |
| 1999 | 3.725344 |
| 2000 | 5.146414 |
| 2001 | 4.254243 |
| 2002 | 4.235987 |
| 2003 | 4.168882 |
| 2004 | 3.583663 |
| 2005 | 4.153155 |
| 2006 | 3.998168 |
| 2007 | 5.441392 |
| 2008 | 3.777486 |
| 2009 | 4.660078 |
| 2010 | 5.452854 |
| 2011 | 4.314434 |
| 2012 | 4.798875 |
| 2013 | 4.928294 |
| 2014 | 5.031838 |
| 2015 | 3.545866 |
| 2016 | 3.782657 |
| 2017 | 4.080446 |
| 2018 | 5.006451 |
| 2021 | 4.307061 |
| 2022 | 5.042935 |
ggplot(fall_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_607 <- mk.test(fall_standard_dev_all_607$sd_2)
print(fall_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_607$sd_2
## z = -0.10846, n = 33, p-value = 0.9136
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -8.00000000 4165.33333333 -0.01515152
fall_sd_sens_607 <- sens.slope(fall_standard_dev_all_607$sd_2)
print(fall_sd_sens_607)
##
## Sen's slope
##
## data: fall_standard_dev_all_607$sd_2
## z = -0.10846, n = 33, p-value = 0.9136
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03420965 0.02687993
## sample estimates:
## Sen's slope
## -0.002817513
Spring
spring_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_607_ad <- spring_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.792166 |
| 1988 | 4.435225 |
| 1989 | 4.395822 |
| 1990 | 3.312270 |
| 1991 | 4.697121 |
| 1992 | 3.235478 |
| 1993 | 3.804221 |
| 1995 | 2.904572 |
| 1996 | 4.367824 |
| 1997 | 5.105000 |
| 1998 | 4.085231 |
| 1999 | 4.825505 |
| 2000 | 4.816459 |
| 2001 | 3.906753 |
| 2002 | 3.321743 |
| 2003 | 4.732830 |
| 2004 | 3.750452 |
| 2005 | 3.994991 |
| 2006 | 3.529357 |
| 2007 | 4.116541 |
| 2008 | 4.982653 |
| 2009 | 4.872110 |
| 2010 | 4.645975 |
| 2011 | 3.829701 |
| 2012 | 3.647358 |
| 2013 | 5.316949 |
| 2014 | 5.007167 |
| 2015 | 2.886453 |
| 2016 | 3.661504 |
| 2017 | 4.108476 |
| 2018 | 4.401548 |
| 2021 | 4.205621 |
| 2022 | 4.824637 |
ggplot(spring_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average spring temperatures for water years 1986-2021
spring_sd_mk_607_ad <- mk.test(spring_standard_dev_all_607_ad$sd_2)
print(spring_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_607_ad$sd_2
## z = 0.91417, n = 33, p-value = 0.3606
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 60.0000000 4165.3333333 0.1136364
spring_sd_sens_607_ad <- sens.slope(spring_standard_dev_all_607_ad$sd_2)
print(spring_sd_sens_607_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_607_ad$sd_2
## z = 0.91417, n = 33, p-value = 0.3606
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01632093 0.03551908
## sample estimates:
## Sen's slope
## 0.01291122
Fall
fall_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_607_ad <- fall_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.831631 |
| 1988 | 3.690072 |
| 1989 | 3.614589 |
| 1990 | 5.286276 |
| 1991 | 4.190874 |
| 1992 | 5.046122 |
| 1993 | 3.163708 |
| 1995 | 4.531313 |
| 1996 | 4.681893 |
| 1997 | 5.700106 |
| 1998 | 5.679713 |
| 1999 | 3.408147 |
| 2000 | 4.698438 |
| 2001 | 3.864718 |
| 2002 | 3.861645 |
| 2003 | 3.813140 |
| 2004 | 3.262366 |
| 2005 | 3.791061 |
| 2006 | 3.600417 |
| 2007 | 5.442241 |
| 2008 | 3.777610 |
| 2009 | 4.660498 |
| 2010 | 5.454247 |
| 2011 | 4.317176 |
| 2012 | 4.800259 |
| 2013 | 4.927996 |
| 2014 | 5.032401 |
| 2015 | 3.549347 |
| 2016 | 3.783353 |
| 2017 | 4.079443 |
| 2018 | 5.009964 |
| 2021 | 4.305087 |
| 2022 | 5.044438 |
ggplot(fall_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_607_ad <- mk.test(fall_standard_dev_all_607_ad$sd_2)
print(fall_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_607_ad$sd_2
## z = 0.72824, n = 33, p-value = 0.4665
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 4.800000e+01 4.165333e+03 9.090909e-02
fall_sd_sens_607_ad <- sens.slope(fall_standard_dev_all_607_ad$sd_2)
print(fall_sd_sens_607_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_607_ad$sd_2
## z = 0.72824, n = 33, p-value = 0.4665
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01841429 0.04105146
## sample estimates:
## Sen's slope
## 0.01330915
Morrisey 8/7/2006
snotel_709 <- SNOTEL_yampa_area %>%
filter(site_id == "709")
#str(snotel_709) # check the date, usually a character.
snotel_709$Date <- as.Date(snotel_709$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_709_clean <- snotel_709 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_709_clean <- snotel_709_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_709_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_709_clean <- snotel_709_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_709_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_709_cull_count <- snotel_709_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_709_cull_count
# filtering for too few observations in a year
snotel_709_cull_count_days <- snotel_709_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_709_cull_count_days
## # A tibble: 14 x 2
## # Groups: waterYear [14]
## waterYear n
## <dbl> <int>
## 1 1992 318
## 2 1993 293
## 3 1994 332
## 4 1995 169
## 5 2006 348
## 6 2007 311
## 7 2011 292
## 8 2012 308
## 9 2013 300
## 10 2014 283
## 11 2015 44
## 12 2016 18
## 13 2017 34
## 14 2018 147
snotel_709_clean_culled <- snotel_709_clean %>%
filter(waterYear > "1995" & waterYear != "2006" & waterYear != "2007" & waterYear != "2011" & waterYear != "2012" & waterYear != "2013" & waterYear != "2014" & waterYear != "2015" & waterYear != "2016" & waterYear != "2017" & waterYear != "2018")# & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_709_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_709_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_709_xts <- xts(snotel_709_clean_culled$temperature_mean, order.by = snotel_709_clean_culled$Date)
dygraph(temp_709_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_709_clean_culled <- snotel_709_clean_culled %>%
# filter(temperature_mean > -30)
#temp_709_xts <- xts(snotel_709_clean_culled$temperature_mean, order.by = snotel_709_clean_culled$Date)
#dygraph(temp_709_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_709_adjusted <- snotel_709_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-08-07", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_709 <- snotel_709_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_709 <- yearly_wy_aver_709 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_709 <- daily_wy_aver_709 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_709$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_709 <-daily_wy_aver_709 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_709$date_temp <- signif(daily_wy_aver2_709$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_709, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_709 <- daily_wy_aver_709 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_709 <- standard_dev_709 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_709 <- standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 8.845436 |
| 1997 | 8.864608 |
| 1998 | 9.079136 |
| 1999 | 8.309577 |
| 2000 | 8.748503 |
| 2001 | 9.426260 |
| 2002 | 9.843776 |
| 2003 | 9.011443 |
| 2004 | 8.578795 |
| 2005 | 8.457080 |
| 2008 | 9.038776 |
| 2009 | 8.123905 |
| 2010 | 8.958458 |
| 2019 | 8.740431 |
| 2020 | 9.196584 |
| 2021 | 9.081772 |
| 2022 | 8.759943 |
ggplot(standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average temperatures for water years 2005-2021
sd_mk_709 <- mk.test(standard_dev_all_709$sd_2)
print(sd_mk_709)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_709$sd_2
## z = 0.041193, n = 17, p-value = 0.9671
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.00000000 589.33333333 0.01470588
sd_sens_709 <- sens.slope(standard_dev_all_709$sd_2)
print(sd_sens_709)
##
## Sen's slope
##
## data: standard_dev_all_709$sd_2
## z = 0.041193, n = 17, p-value = 0.9671
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04647212 0.03945218
## sample estimates:
## Sen's slope
## 0.0005780099
#using the clean culled df:
#average water year temperature
yearly_wy_aver_709_ad <- snotel_709_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_709_ad <- yearly_wy_aver_709_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_709_ad <- daily_wy_aver_709_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_709_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_709_ad <-daily_wy_aver_709_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_709_ad$date_temp_ad <- signif(daily_wy_aver2_709_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_709_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_709_ad <- daily_wy_aver_709_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_709_ad <- standard_dev_709_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_709_ad <- standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 8.213076 |
| 1997 | 8.255603 |
| 1998 | 8.412792 |
| 1999 | 7.726856 |
| 2000 | 8.073670 |
| 2001 | 8.727586 |
| 2002 | 9.142221 |
| 2003 | 8.322566 |
| 2004 | 7.979937 |
| 2005 | 7.819602 |
| 2008 | 9.038980 |
| 2009 | 8.124255 |
| 2010 | 8.958543 |
| 2019 | 8.740727 |
| 2020 | 9.196244 |
| 2021 | 9.081146 |
| 2022 | 8.760212 |
ggplot(standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average temperatures for water years 1986-2021
sd_mk_709_ad <- mk.test(standard_dev_all_709_ad$sd_2)
print(sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_709_ad$sd_2
## z = 1.9361, n = 17, p-value = 0.05286
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 48.0000000 589.3333333 0.3529412
sd_sens_709_ad <- sens.slope(standard_dev_all_709_ad$sd_2)
print(sd_sens_709_ad)
##
## Sen's slope
##
## data: standard_dev_all_709_ad$sd_2
## z = 1.9361, n = 17, p-value = 0.05286
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.006786111 0.102902003
## sample estimates:
## Sen's slope
## 0.05101403
summer_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_709 <- summer_standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 2.699357 |
| 1997 | 2.803136 |
| 1998 | 4.299417 |
| 1999 | 2.943569 |
| 2000 | 3.135018 |
| 2001 | 3.498579 |
| 2002 | 3.242702 |
| 2003 | 4.267552 |
| 2004 | 3.237389 |
| 2005 | 4.369069 |
| 2008 | 3.658282 |
| 2009 | 3.336066 |
| 2010 | 2.920813 |
| 2019 | 3.554948 |
| 2020 | 3.162425 |
| 2021 | 2.844119 |
| 2022 | 2.832435 |
ggplot(summer_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average summer temperatures for water years 2005-2021
summer_sd_mk_709 <- mk.test(summer_standard_dev_all_709$sd_2)
print(summer_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_709$sd_2
## z = 0, n = 17, p-value = 1
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 0.0000 589.3333 0.0000
summer_sd_sens_709 <- sens.slope(summer_standard_dev_all_709$sd_2)
print(summer_sd_sens_709)
##
## Sen's slope
##
## data: summer_standard_dev_all_709$sd_2
## z = 0, n = 17, p-value = 1
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.06767895 0.05876401
## sample estimates:
## Sen's slope
## -0.0002875385
Winter
winter_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_709 <- winter_standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 5.106503 |
| 1997 | 5.310543 |
| 1998 | 4.460035 |
| 1999 | 5.352155 |
| 2000 | 4.929995 |
| 2001 | 4.039659 |
| 2002 | 5.575255 |
| 2003 | 4.226745 |
| 2004 | 5.281661 |
| 2005 | 4.220734 |
| 2008 | 5.455698 |
| 2009 | 4.979663 |
| 2010 | 5.144629 |
| 2019 | 4.172209 |
| 2020 | 4.774968 |
| 2021 | 4.693494 |
| 2022 | 5.410537 |
ggplot(winter_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average winter temperatures for water years 2005-2021
winter_sd_mk_709 <- mk.test(winter_standard_dev_all_709$sd_2)
print(winter_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_709$sd_2
## z = -0.28835, n = 17, p-value = 0.7731
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -8.00000000 589.33333333 -0.05882353
winter_sd_sens_709 <- sens.slope(winter_standard_dev_all_709$sd_2)
print(winter_sd_sens_709)
##
## Sen's slope
##
## data: winter_standard_dev_all_709$sd_2
## z = -0.28835, n = 17, p-value = 0.7731
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.07177104 0.06538351
## sample estimates:
## Sen's slope
## -0.01031017
Summer
summer_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_709_ad <- summer_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 2.422131 |
| 1997 | 2.514577 |
| 1998 | 3.872163 |
| 1999 | 2.643742 |
| 2000 | 2.808001 |
| 2001 | 3.149591 |
| 2002 | 2.906430 |
| 2003 | 3.828930 |
| 2004 | 2.905695 |
| 2005 | 3.932145 |
| 2008 | 3.658608 |
| 2009 | 3.336298 |
| 2010 | 2.920827 |
| 2019 | 3.554534 |
| 2020 | 3.162811 |
| 2021 | 2.845538 |
| 2022 | 2.833259 |
ggplot(summer_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average summer temperatures for water years 1986-2021
summer_sd_mk_709_ad <- mk.test(summer_standard_dev_all_709_ad$sd_2)
print(summer_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_709_ad$sd_2
## z = 0.94743, n = 17, p-value = 0.3434
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 24.0000000 589.3333333 0.1764706
summer_sd_sens_709_ad <- sens.slope(summer_standard_dev_all_709_ad$sd_2)
print(summer_sd_sens_709_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_709_ad$sd_2
## z = 0.94743, n = 17, p-value = 0.3434
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03040527 0.08294809
## sample estimates:
## Sen's slope
## 0.02505948
Winter
winter_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_709_ad <- winter_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.930025 |
| 1997 | 5.120522 |
| 1998 | 4.293505 |
| 1999 | 5.156522 |
| 2000 | 4.695941 |
| 2001 | 3.905749 |
| 2002 | 5.373883 |
| 2003 | 4.069151 |
| 2004 | 5.076455 |
| 2005 | 4.074418 |
| 2008 | 5.455817 |
| 2009 | 4.979677 |
| 2010 | 5.143753 |
| 2019 | 4.172002 |
| 2020 | 4.773580 |
| 2021 | 4.691618 |
| 2022 | 5.411277 |
ggplot(winter_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average winter temperatures for water years 1986-2021
winter_sd_mk_709_ad <- mk.test(winter_standard_dev_all_709_ad$sd_2)
print(winter_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_709_ad$sd_2
## z = 0.37073, n = 17, p-value = 0.7108
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 10.00000000 589.33333333 0.07352941
winter_sd_sens_709_ad <- sens.slope(winter_standard_dev_all_709_ad$sd_2)
print(winter_sd_sens_709_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_709_ad$sd_2
## z = 0.37073, n = 17, p-value = 0.7108
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05497659 0.07397628
## sample estimates:
## Sen's slope
## 0.01229432
spring_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_709 <- spring_standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.961758 |
| 1997 | 5.749369 |
| 1998 | 4.880162 |
| 1999 | 5.429883 |
| 2000 | 5.493531 |
| 2001 | 4.662608 |
| 2002 | 4.210844 |
| 2003 | 5.522668 |
| 2004 | 4.547940 |
| 2005 | 4.667549 |
| 2008 | 5.460987 |
| 2009 | 4.852970 |
| 2010 | 5.130312 |
| 2019 | 3.747774 |
| 2020 | 5.312329 |
| 2021 | 4.651057 |
| 2022 | 5.170204 |
ggplot(spring_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average spring temperatures for water years 2005-2021
spring_sd_mk_709 <- mk.test(spring_standard_dev_all_709$sd_2)
print(spring_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_709$sd_2
## z = -0.94743, n = 17, p-value = 0.3434
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -24.0000000 589.3333333 -0.1764706
spring_sd_sens_709 <- sens.slope(spring_standard_dev_all_709$sd_2)
print(spring_sd_sens_709)
##
## Sen's slope
##
## data: spring_standard_dev_all_709$sd_2
## z = -0.94743, n = 17, p-value = 0.3434
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.07658854 0.03601394
## sample estimates:
## Sen's slope
## -0.02849617
Fall
fall_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_709 <- fall_standard_dev_all_709 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 5.932014 |
| 1997 | 6.445757 |
| 1998 | 6.578772 |
| 1999 | 4.299547 |
| 2000 | 5.334342 |
| 2001 | 4.995401 |
| 2002 | 4.932738 |
| 2003 | 4.953106 |
| 2004 | 4.277464 |
| 2005 | 4.944449 |
| 2008 | 4.257028 |
| 2009 | 5.070610 |
| 2010 | 6.669413 |
| 2019 | 5.833757 |
| 2020 | 8.124688 |
| 2021 | 6.124060 |
| 2022 | 5.828747 |
ggplot(fall_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_709 <- mk.test(fall_standard_dev_all_709$sd_2)
print(fall_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_709$sd_2
## z = 0.37073, n = 17, p-value = 0.7108
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 10.00000000 589.33333333 0.07352941
fall_sd_sens_709 <- sens.slope(fall_standard_dev_all_709$sd_2)
print(fall_sd_sens_709)
##
## Sen's slope
##
## data: fall_standard_dev_all_709$sd_2
## z = 0.37073, n = 17, p-value = 0.7108
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.1097295 0.1467752
## sample estimates:
## Sen's slope
## 0.02035028
Spring
spring_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_709_ad <- spring_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.577393 |
| 1997 | 5.386836 |
| 1998 | 4.480441 |
| 1999 | 5.050192 |
| 2000 | 5.032683 |
| 2001 | 4.284041 |
| 2002 | 3.840149 |
| 2003 | 5.078124 |
| 2004 | 4.167201 |
| 2005 | 4.283564 |
| 2008 | 5.461295 |
| 2009 | 4.853354 |
| 2010 | 5.130526 |
| 2019 | 3.748868 |
| 2020 | 5.312411 |
| 2021 | 4.651507 |
| 2022 | 5.171008 |
ggplot(spring_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average spring temperatures for water years 1986-2021
spring_sd_mk_709_ad <- mk.test(spring_standard_dev_all_709_ad$sd_2)
print(spring_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_709_ad$sd_2
## z = 0.28835, n = 17, p-value = 0.7731
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 8.00000000 589.33333333 0.05882353
spring_sd_sens_709_ad <- sens.slope(spring_standard_dev_all_709_ad$sd_2)
print(spring_sd_sens_709_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_709_ad$sd_2
## z = 0.28835, n = 17, p-value = 0.7731
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05252350 0.07143543
## sample estimates:
## Sen's slope
## 0.009109751
Fall
fall_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_709_ad <- fall_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 5.438862 |
| 1997 | 5.951660 |
| 1998 | 6.027430 |
| 1999 | 3.937921 |
| 2000 | 4.871095 |
| 2001 | 4.540389 |
| 2002 | 4.507880 |
| 2003 | 4.539273 |
| 2004 | 3.890384 |
| 2005 | 4.511996 |
| 2008 | 4.259072 |
| 2009 | 5.074536 |
| 2010 | 6.670606 |
| 2019 | 5.836610 |
| 2020 | 8.126309 |
| 2021 | 6.123439 |
| 2022 | 5.829070 |
ggplot(fall_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_709_ad <- mk.test(fall_standard_dev_all_709_ad$sd_2)
print(fall_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_709_ad$sd_2
## z = 0.94743, n = 17, p-value = 0.3434
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 24.0000000 589.3333333 0.1764706
fall_sd_sens_709_ad <- sens.slope(fall_standard_dev_all_709_ad$sd_2)
print(fall_sd_sens_709_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_709_ad$sd_2
## z = 0.94743, n = 17, p-value = 0.3434
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.06220226 0.18981847
## sample estimates:
## Sen's slope
## 0.07780033
Oyler -> Morrisey 8/7/2006
snotel_717 <- SNOTEL_yampa_area %>%
filter(site_id == "717")
#str(snotel_717) # check the date, usually a character.
snotel_717$Date <- as.Date(snotel_717$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_717_clean <- snotel_717 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_717_clean <- snotel_717_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_717_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_717_clean <- snotel_717_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_717_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_717_cull_count <- snotel_717_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_717_cull_count
# filtering for too few observations in a year
snotel_717_cull_count_days <- snotel_717_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_717_cull_count_days
## # A tibble: 2 x 2
## # Groups: waterYear [2]
## waterYear n
## <dbl> <int>
## 1 1992 311
## 2 1993 330
snotel_717_clean_culled <- snotel_717_clean %>%
filter(waterYear != "1992" & waterYear != "1993")# & waterYear != "2007" & waterYear != "2011" & waterYear != "2012" & waterYear != "2013" & waterYear != "2014" & waterYear != "2015" & waterYear != "2016" & waterYear != "2017" & waterYear != "2018")# & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_717_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_717_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_717_xts <- xts(snotel_717_clean_culled$temperature_mean, order.by = snotel_717_clean_culled$Date)
dygraph(temp_717_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_717_clean_culled <- snotel_717_clean_culled %>%
# filter(temperature_mean > -30)
#temp_717_xts <- xts(snotel_717_clean_culled$temperature_mean, order.by = snotel_717_clean_culled$Date)
#dygraph(temp_717_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_717_adjusted <- snotel_717_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-08-07", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_717 <- snotel_717_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_717 <- yearly_wy_aver_717 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_717 <- daily_wy_aver_717 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_717$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_717 <-daily_wy_aver_717 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_717$date_temp <- signif(daily_wy_aver2_717$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_717, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_717 <- daily_wy_aver_717 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_717 <- standard_dev_717 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_717 <- standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.803468 |
| 1988 | 9.707652 |
| 1989 | 9.270222 |
| 1990 | 9.163954 |
| 1991 | 9.043756 |
| 1994 | 9.475534 |
| 1995 | 8.216129 |
| 1996 | 8.766674 |
| 1997 | 8.761084 |
| 1998 | 8.941067 |
| 1999 | 8.106802 |
| 2000 | 8.669178 |
| 2001 | 9.209650 |
| 2002 | 9.676307 |
| 2003 | 9.008971 |
| 2004 | 8.362946 |
| 2005 | 8.373378 |
| 2006 | 9.248617 |
| 2007 | 8.800246 |
| 2008 | 8.921082 |
| 2009 | 7.998549 |
| 2010 | 8.681956 |
| 2011 | 8.605749 |
| 2012 | 8.582569 |
| 2013 | 9.046302 |
| 2014 | 8.329385 |
| 2015 | 7.737981 |
| 2016 | 8.402920 |
| 2017 | 8.250374 |
| 2018 | 8.202730 |
| 2019 | 8.544093 |
| 2020 | 8.992894 |
| 2021 | 8.957109 |
| 2022 | 8.519914 |
ggplot(standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average temperatures for water years 2005-2021
sd_mk_717 <- mk.test(standard_dev_all_717$sd_2)
print(sd_mk_717)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_717$sd_2
## z = -2.6684, n = 34, p-value = 0.007621
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -181.0000000 4550.3333333 -0.3226381
sd_sens_717 <- sens.slope(standard_dev_all_717$sd_2)
print(sd_sens_717)
##
## Sen's slope
##
## data: standard_dev_all_717$sd_2
## z = -2.6684, n = 34, p-value = 0.007621
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.039224947 -0.006265457
## sample estimates:
## Sen's slope
## -0.02259117
#using the clean culled df:
#average water year temperature
yearly_wy_aver_717_ad <- snotel_717_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_717_ad <- yearly_wy_aver_717_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_717_ad <- daily_wy_aver_717_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_717_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_717_ad <-daily_wy_aver_717_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_717_ad$date_temp_ad <- signif(daily_wy_aver2_717_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_717_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_717_ad <- daily_wy_aver_717_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_717_ad <- standard_dev_717_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_717_ad <- standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.203857 |
| 1988 | 9.063074 |
| 1989 | 8.683957 |
| 1990 | 8.529404 |
| 1991 | 8.477488 |
| 1994 | 8.832494 |
| 1995 | 7.643847 |
| 1996 | 8.162790 |
| 1997 | 8.181297 |
| 1998 | 8.315921 |
| 1999 | 7.566445 |
| 2000 | 8.038773 |
| 2001 | 8.563752 |
| 2002 | 9.013927 |
| 2003 | 8.355528 |
| 2004 | 7.809021 |
| 2005 | 7.779504 |
| 2006 | 8.600879 |
| 2007 | 8.799659 |
| 2008 | 8.920535 |
| 2009 | 7.997923 |
| 2010 | 8.681418 |
| 2011 | 8.605311 |
| 2012 | 8.581992 |
| 2013 | 9.045623 |
| 2014 | 8.328989 |
| 2015 | 7.737670 |
| 2016 | 8.402569 |
| 2017 | 8.249042 |
| 2018 | 8.202635 |
| 2019 | 8.543763 |
| 2020 | 8.992050 |
| 2021 | 8.956530 |
| 2022 | 8.520306 |
ggplot(standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average temperatures for water years 1986-2021
sd_mk_717_ad <- mk.test(standard_dev_all_717_ad$sd_2)
print(sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_717_ad$sd_2
## z = 0.56333, n = 34, p-value = 0.5732
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.900000e+01 4.550333e+03 6.951872e-02
sd_sens_717_ad <- sens.slope(standard_dev_all_717_ad$sd_2)
print(sd_sens_717_ad)
##
## Sen's slope
##
## data: standard_dev_all_717_ad$sd_2
## z = 0.56333, n = 34, p-value = 0.5732
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01114957 0.02335425
## sample estimates:
## Sen's slope
## 0.004691148
summer_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_717 <- summer_standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.224524 |
| 1988 | 2.913873 |
| 1989 | 3.965750 |
| 1990 | 3.477345 |
| 1991 | 3.013326 |
| 1994 | 2.642524 |
| 1995 | 4.133728 |
| 1996 | 2.662578 |
| 1997 | 2.803395 |
| 1998 | 4.401717 |
| 1999 | 3.011363 |
| 2000 | 3.012336 |
| 2001 | 3.274224 |
| 2002 | 3.122130 |
| 2003 | 4.156044 |
| 2004 | 3.235294 |
| 2005 | 4.330234 |
| 2006 | 2.921640 |
| 2007 | 3.232601 |
| 2008 | 3.510428 |
| 2009 | 3.439849 |
| 2010 | 2.848043 |
| 2011 | 2.858293 |
| 2012 | 2.286914 |
| 2013 | 2.290334 |
| 2014 | 2.897724 |
| 2015 | 2.577398 |
| 2016 | 2.388211 |
| 2017 | 2.305004 |
| 2018 | 2.543229 |
| 2019 | 3.362477 |
| 2020 | 3.162736 |
| 2021 | 2.973319 |
| 2022 | 2.720584 |
ggplot(summer_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average summer temperatures for water years 2005-2021
summer_sd_mk_717 <- mk.test(summer_standard_dev_all_717$sd_2)
print(summer_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_717$sd_2
## z = -2.0161, n = 34, p-value = 0.04379
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -137.0000000 4550.3333333 -0.2442068
summer_sd_sens_717 <- sens.slope(summer_standard_dev_all_717$sd_2)
print(summer_sd_sens_717)
##
## Sen's slope
##
## data: summer_standard_dev_all_717$sd_2
## z = -2.0161, n = 34, p-value = 0.04379
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0392421290 -0.0003271967
## sample estimates:
## Sen's slope
## -0.01792769
Winter
winter_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_717 <- winter_standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.657343 |
| 1988 | 5.261519 |
| 1989 | 5.986867 |
| 1990 | 5.022740 |
| 1991 | 5.460920 |
| 1994 | 4.876599 |
| 1995 | 4.786968 |
| 1996 | 4.875585 |
| 1997 | 5.045003 |
| 1998 | 4.331788 |
| 1999 | 5.104108 |
| 2000 | 5.096680 |
| 2001 | 4.035442 |
| 2002 | 5.430552 |
| 2003 | 4.168979 |
| 2004 | 5.243099 |
| 2005 | 4.241822 |
| 2006 | 5.326377 |
| 2007 | 5.641662 |
| 2008 | 5.513466 |
| 2009 | 4.960597 |
| 2010 | 4.982367 |
| 2011 | 5.396133 |
| 2012 | 4.767250 |
| 2013 | 5.794320 |
| 2014 | 4.664987 |
| 2015 | 5.123643 |
| 2016 | 4.730963 |
| 2017 | 5.947760 |
| 2018 | 4.463893 |
| 2019 | 4.176574 |
| 2020 | 4.730622 |
| 2021 | 4.671717 |
| 2022 | 5.357286 |
ggplot(winter_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average winter temperatures for water years 2005-2021
winter_sd_mk_717 <- mk.test(winter_standard_dev_all_717$sd_2)
print(winter_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_717$sd_2
## z = -0.41508, n = 34, p-value = 0.6781
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -29.0000000 4550.3333333 -0.0516934
winter_sd_sens_717 <- sens.slope(winter_standard_dev_all_717$sd_2)
print(winter_sd_sens_717)
##
## Sen's slope
##
## data: winter_standard_dev_all_717$sd_2
## z = -0.41508, n = 34, p-value = 0.6781
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02252599 0.01965227
## sample estimates:
## Sen's slope
## -0.00382438
Summer
summer_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_717_ad <- summer_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.899474 |
| 1988 | 2.616863 |
| 1989 | 3.563651 |
| 1990 | 3.125813 |
| 1991 | 2.710970 |
| 1994 | 2.369712 |
| 1995 | 3.724723 |
| 1996 | 2.388351 |
| 1997 | 2.518185 |
| 1998 | 3.971218 |
| 1999 | 2.710613 |
| 2000 | 2.701215 |
| 2001 | 2.950276 |
| 2002 | 2.799770 |
| 2003 | 3.730300 |
| 2004 | 2.911441 |
| 2005 | 3.901815 |
| 2006 | 2.701929 |
| 2007 | 3.232943 |
| 2008 | 3.509046 |
| 2009 | 3.438972 |
| 2010 | 2.846663 |
| 2011 | 2.856556 |
| 2012 | 2.286845 |
| 2013 | 2.288906 |
| 2014 | 2.898534 |
| 2015 | 2.577007 |
| 2016 | 2.388849 |
| 2017 | 2.304270 |
| 2018 | 2.542963 |
| 2019 | 3.361292 |
| 2020 | 3.162680 |
| 2021 | 2.972913 |
| 2022 | 2.720925 |
ggplot(summer_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average summer temperatures for water years 1986-2021
summer_sd_mk_717_ad <- mk.test(summer_standard_dev_all_717_ad$sd_2)
print(summer_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_717_ad$sd_2
## z = -0.59298, n = 34, p-value = 0.5532
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -41.00000000 4550.33333333 -0.07308378
summer_sd_sens_717_ad <- sens.slope(summer_standard_dev_all_717_ad$sd_2)
print(summer_sd_sens_717_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_717_ad$sd_2
## z = -0.59298, n = 34, p-value = 0.5532
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02257457 0.01147725
## sample estimates:
## Sen's slope
## -0.0058497
Winter
winter_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_717_ad <- winter_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.511864 |
| 1988 | 5.120155 |
| 1989 | 5.835938 |
| 1990 | 4.866078 |
| 1991 | 5.357842 |
| 1994 | 4.755476 |
| 1995 | 4.622944 |
| 1996 | 4.728477 |
| 1997 | 4.866870 |
| 1998 | 4.188722 |
| 1999 | 4.939686 |
| 2000 | 4.882366 |
| 2001 | 3.927303 |
| 2002 | 5.258566 |
| 2003 | 4.042901 |
| 2004 | 5.062301 |
| 2005 | 4.122266 |
| 2006 | 5.182912 |
| 2007 | 5.641987 |
| 2008 | 5.513992 |
| 2009 | 4.960082 |
| 2010 | 4.982376 |
| 2011 | 5.396738 |
| 2012 | 4.767344 |
| 2013 | 5.794738 |
| 2014 | 4.664627 |
| 2015 | 5.123888 |
| 2016 | 4.730546 |
| 2017 | 5.945884 |
| 2018 | 4.464587 |
| 2019 | 4.177248 |
| 2020 | 4.730590 |
| 2021 | 4.671938 |
| 2022 | 5.357714 |
ggplot(winter_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average winter temperatures for water years 1986-2021
winter_sd_mk_717_ad <- mk.test(winter_standard_dev_all_717_ad$sd_2)
print(winter_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_717_ad$sd_2
## z = 0.29649, n = 34, p-value = 0.7669
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.100000e+01 4.550333e+03 3.743316e-02
winter_sd_sens_717_ad <- sens.slope(winter_standard_dev_all_717_ad$sd_2)
print(winter_sd_sens_717_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_717_ad$sd_2
## z = 0.29649, n = 34, p-value = 0.7669
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01603687 0.02452307
## sample estimates:
## Sen's slope
## 0.002160899
spring_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_717 <- spring_standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.191746 |
| 1988 | 5.052698 |
| 1989 | 4.709550 |
| 1990 | 3.586421 |
| 1991 | 4.993788 |
| 1994 | 5.067338 |
| 1995 | 3.599628 |
| 1996 | 5.038972 |
| 1997 | 5.919944 |
| 1998 | 4.678764 |
| 1999 | 5.514574 |
| 2000 | 5.253532 |
| 2001 | 4.838850 |
| 2002 | 4.264652 |
| 2003 | 5.744439 |
| 2004 | 4.094949 |
| 2005 | 4.732194 |
| 2006 | 4.322124 |
| 2007 | 4.538706 |
| 2008 | 5.290824 |
| 2009 | 4.727389 |
| 2010 | 4.909031 |
| 2011 | 4.138610 |
| 2012 | 4.222271 |
| 2013 | 5.403716 |
| 2014 | 5.330093 |
| 2015 | 3.039021 |
| 2016 | 3.900014 |
| 2017 | 4.524965 |
| 2018 | 4.813970 |
| 2019 | 3.475528 |
| 2020 | 5.127346 |
| 2021 | 4.487625 |
| 2022 | 5.037238 |
ggplot(spring_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average spring temperatures for water years 2005-2021
spring_sd_mk_717 <- mk.test(spring_standard_dev_all_717$sd_2)
print(spring_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_717$sd_2
## z = -0.59298, n = 34, p-value = 0.5532
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -41.00000000 4550.33333333 -0.07308378
spring_sd_sens_717 <- sens.slope(spring_standard_dev_all_717$sd_2)
print(spring_sd_sens_717)
##
## Sen's slope
##
## data: spring_standard_dev_all_717$sd_2
## z = -0.59298, n = 34, p-value = 0.5532
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03408638 0.01601456
## sample estimates:
## Sen's slope
## -0.007918443
Fall
fall_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_717 <- fall_standard_dev_all_717 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.829074 |
| 1988 | 4.592608 |
| 1989 | 3.840921 |
| 1990 | 6.449781 |
| 1991 | 4.748972 |
| 1994 | 5.369802 |
| 1995 | 5.490723 |
| 1996 | 5.649010 |
| 1997 | 6.451207 |
| 1998 | 6.353280 |
| 1999 | 4.231361 |
| 2000 | 5.053277 |
| 2001 | 4.989095 |
| 2002 | 5.055589 |
| 2003 | 4.837551 |
| 2004 | 4.278815 |
| 2005 | 4.960265 |
| 2006 | 4.418937 |
| 2007 | 5.564753 |
| 2008 | 4.203698 |
| 2009 | 4.870633 |
| 2010 | 6.578648 |
| 2011 | 4.639124 |
| 2012 | 5.167305 |
| 2013 | 5.112164 |
| 2014 | 5.689813 |
| 2015 | 4.111843 |
| 2016 | 4.107355 |
| 2017 | 4.638282 |
| 2018 | 5.346645 |
| 2019 | 5.639300 |
| 2020 | 7.441051 |
| 2021 | 5.658179 |
| 2022 | 5.912735 |
ggplot(fall_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_717 <- mk.test(fall_standard_dev_all_717$sd_2)
print(fall_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_717$sd_2
## z = 0.88947, n = 34, p-value = 0.3738
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 61.0000000 4550.3333333 0.1087344
fall_sd_sens_717 <- sens.slope(fall_standard_dev_all_717$sd_2)
print(fall_sd_sens_717)
##
## Sen's slope
##
## data: fall_standard_dev_all_717$sd_2
## z = 0.88947, n = 34, p-value = 0.3738
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02029376 0.04012974
## sample estimates:
## Sen's slope
## 0.01117152
Spring
spring_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_717_ad <- spring_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.861349 |
| 1988 | 4.669349 |
| 1989 | 4.340253 |
| 1990 | 3.313149 |
| 1991 | 4.649131 |
| 1994 | 4.680839 |
| 1995 | 3.366496 |
| 1996 | 4.676035 |
| 1997 | 5.557443 |
| 1998 | 4.325797 |
| 1999 | 5.153647 |
| 2000 | 4.838200 |
| 2001 | 4.468033 |
| 2002 | 3.899764 |
| 2003 | 5.301000 |
| 2004 | 3.769020 |
| 2005 | 4.358014 |
| 2006 | 3.974707 |
| 2007 | 4.537917 |
| 2008 | 5.290634 |
| 2009 | 4.727411 |
| 2010 | 4.908589 |
| 2011 | 4.137864 |
| 2012 | 4.223254 |
| 2013 | 5.403976 |
| 2014 | 5.331024 |
| 2015 | 3.038848 |
| 2016 | 3.900308 |
| 2017 | 4.525017 |
| 2018 | 4.814461 |
| 2019 | 3.475802 |
| 2020 | 5.127249 |
| 2021 | 4.487797 |
| 2022 | 5.037517 |
ggplot(spring_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average spring temperatures for water years 1986-2021
spring_sd_mk_717_ad <- mk.test(spring_standard_dev_all_717_ad$sd_2)
print(spring_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_717_ad$sd_2
## z = 0.83017, n = 34, p-value = 0.4064
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 57.0000000 4550.3333333 0.1016043
spring_sd_sens_717_ad <- sens.slope(spring_standard_dev_all_717_ad$sd_2)
print(spring_sd_sens_717_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_717_ad$sd_2
## z = 0.83017, n = 34, p-value = 0.4064
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01668585 0.03469560
## sample estimates:
## Sen's slope
## 0.009059892
Fall
fall_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_717_ad <- fall_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.426254 |
| 1988 | 4.171212 |
| 1989 | 3.482292 |
| 1990 | 5.923467 |
| 1991 | 4.364527 |
| 1994 | 4.926737 |
| 1995 | 5.015766 |
| 1996 | 5.193636 |
| 1997 | 5.991684 |
| 1998 | 5.847349 |
| 1999 | 3.892248 |
| 2000 | 4.634643 |
| 2001 | 4.548470 |
| 2002 | 4.635844 |
| 2003 | 4.450837 |
| 2004 | 3.908092 |
| 2005 | 4.556853 |
| 2006 | 4.039951 |
| 2007 | 5.564706 |
| 2008 | 4.205595 |
| 2009 | 4.871583 |
| 2010 | 6.579165 |
| 2011 | 4.639026 |
| 2012 | 5.166883 |
| 2013 | 5.109262 |
| 2014 | 5.689258 |
| 2015 | 4.111557 |
| 2016 | 4.107469 |
| 2017 | 4.634844 |
| 2018 | 5.347787 |
| 2019 | 5.639288 |
| 2020 | 7.440060 |
| 2021 | 5.655687 |
| 2022 | 5.911312 |
ggplot(fall_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_717_ad <- mk.test(fall_standard_dev_all_717_ad$sd_2)
print(fall_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_717_ad$sd_2
## z = 2.0161, n = 34, p-value = 0.04379
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 137.0000000 4550.3333333 0.2442068
fall_sd_sens_717_ad <- sens.slope(fall_standard_dev_all_717_ad$sd_2)
print(fall_sd_sens_717_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_717_ad$sd_2
## z = 2.0161, n = 34, p-value = 0.04379
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## 0.0003535516 0.0608410631
## sample estimates:
## Sen's slope
## 0.03220125
Original 8/18/2004
snotel_825 <- SNOTEL_yampa_area %>%
filter(site_id == "825")
#str(snotel_825) # check the date, usually a character.
snotel_825$Date <- as.Date(snotel_825$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_825_clean <- snotel_825 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_825_clean <- snotel_825_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_825_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_825_clean <- snotel_825_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 30)
ggplot(snotel_825_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_825_cull_count <- snotel_825_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_825_cull_count
# filtering for too few observations in a year
snotel_825_cull_count_days <- snotel_825_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_825_cull_count_days
## # A tibble: 9 x 2
## # Groups: waterYear [9]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1987 348
## 3 1994 301
## 4 1995 347
## 5 1997 322
## 6 1998 343
## 7 1999 348
## 8 2002 327
## 9 2008 325
snotel_825_clean_culled <- snotel_825_clean %>%
filter(waterYear > "1987" & waterYear != "1994" & waterYear != "1995" & waterYear != "1997" & waterYear != "1998" & waterYear != "1999" & waterYear != "2002" & waterYear != "2008")# & waterYear != "2017" & waterYear != "2018")# & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_825_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_825_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_825_xts <- xts(snotel_825_clean_culled$temperature_mean, order.by = snotel_825_clean_culled$Date)
dygraph(temp_825_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_825_clean_culled <- snotel_825_clean_culled %>%
# filter(temperature_mean > -30)
#temp_825_xts <- xts(snotel_825_clean_culled$temperature_mean, order.by = snotel_825_clean_culled$Date)
#dygraph(temp_825_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_825_adjusted <- snotel_825_clean_culled %>%
mutate(temp_ad = if_else(Date < "2004-08-18", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_825 <- snotel_825_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_825 <- yearly_wy_aver_825 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_825 <- daily_wy_aver_825 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_825$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_825 <-daily_wy_aver_825 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_825$date_temp <- signif(daily_wy_aver2_825$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_825, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_825 <- daily_wy_aver_825 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_825 <- standard_dev_825 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_825 <- standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 10.158111 |
| 1989 | 9.521283 |
| 1990 | 9.387663 |
| 1991 | 9.495098 |
| 1992 | 8.468342 |
| 1993 | 8.686860 |
| 1996 | 9.236157 |
| 2000 | 8.951568 |
| 2001 | 9.626977 |
| 2003 | 9.317887 |
| 2004 | 8.794074 |
| 2005 | 8.168991 |
| 2006 | 9.046952 |
| 2007 | 9.112464 |
| 2009 | 8.322586 |
| 2010 | 8.961897 |
| 2011 | 8.871929 |
| 2012 | 8.997194 |
| 2013 | 9.382743 |
| 2014 | 8.649080 |
| 2015 | 8.104451 |
| 2016 | 8.792359 |
| 2017 | 8.593127 |
| 2018 | 8.634239 |
| 2019 | 8.862025 |
| 2020 | 9.328094 |
| 2021 | 9.270956 |
| 2022 | 9.124264 |
ggplot(standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average temperatures for water years 2005-2021
sd_mk_825 <- mk.test(standard_dev_all_825$sd_2)
print(sd_mk_825)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_825$sd_2
## z = -1.7188, n = 28, p-value = 0.08565
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -88.0000000 2562.0000000 -0.2328042
sd_sens_825 <- sens.slope(standard_dev_all_825$sd_2)
print(sd_sens_825)
##
## Sen's slope
##
## data: standard_dev_all_825$sd_2
## z = -1.7188, n = 28, p-value = 0.08565
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04047480 0.00485368
## sample estimates:
## Sen's slope
## -0.02125455
#using the clean culled df:
#average water year temperature
yearly_wy_aver_825_ad <- snotel_825_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_825_ad <- yearly_wy_aver_825_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_825_ad <- daily_wy_aver_825_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_825_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_825_ad <-daily_wy_aver_825_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_825_ad$date_temp_ad <- signif(daily_wy_aver2_825_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_825_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_825_ad <- daily_wy_aver_825_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_825_ad <- standard_dev_825_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_825_ad <- standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 9.527196 |
| 1989 | 8.967107 |
| 1990 | 8.793798 |
| 1991 | 8.946793 |
| 1992 | 7.952054 |
| 1993 | 8.156645 |
| 1996 | 8.650702 |
| 2000 | 8.338506 |
| 2001 | 8.985410 |
| 2003 | 8.675745 |
| 2004 | 8.209448 |
| 2005 | 8.172186 |
| 2006 | 9.049660 |
| 2007 | 9.115791 |
| 2009 | 8.324666 |
| 2010 | 8.964371 |
| 2011 | 8.875058 |
| 2012 | 9.001462 |
| 2013 | 9.386059 |
| 2014 | 8.652436 |
| 2015 | 8.107386 |
| 2016 | 8.796286 |
| 2017 | 8.596142 |
| 2018 | 8.637340 |
| 2019 | 8.865259 |
| 2020 | 9.331765 |
| 2021 | 9.273785 |
| 2022 | 9.127176 |
ggplot(standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average temperatures for water years 1986-2021
sd_mk_825_ad <- mk.test(standard_dev_all_825_ad$sd_2)
print(sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_825_ad$sd_2
## z = 1.0076, n = 28, p-value = 0.3137
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 52.0000000 2562.0000000 0.1375661
sd_sens_825_ad <- sens.slope(standard_dev_all_825_ad$sd_2)
print(sd_sens_825_ad)
##
## Sen's slope
##
## data: standard_dev_all_825_ad$sd_2
## z = 1.0076, n = 28, p-value = 0.3137
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.009639429 0.034852064
## sample estimates:
## Sen's slope
## 0.01232876
Trapper Lake 827 Original 12/13/2004
summer_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_825 <- summer_standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 2.937324 |
| 1989 | 4.131031 |
| 1990 | 3.552285 |
| 1991 | 3.012605 |
| 1992 | 3.661890 |
| 1993 | 3.791086 |
| 1996 | 2.766578 |
| 2000 | 3.310495 |
| 2001 | 3.706866 |
| 2003 | 4.502144 |
| 2004 | 3.391035 |
| 2005 | 4.165727 |
| 2006 | 2.864859 |
| 2007 | 3.451906 |
| 2009 | 3.647451 |
| 2010 | 3.005471 |
| 2011 | 3.147523 |
| 2012 | 2.515005 |
| 2013 | 2.467694 |
| 2014 | 3.112656 |
| 2015 | 2.575461 |
| 2016 | 2.528024 |
| 2017 | 2.406348 |
| 2018 | 2.739231 |
| 2019 | 3.587064 |
| 2020 | 3.409729 |
| 2021 | 3.071883 |
| 2022 | 3.010550 |
ggplot(summer_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average summer temperatures for water years 2005-2021
summer_sd_mk_825 <- mk.test(summer_standard_dev_all_825$sd_2)
print(summer_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_825$sd_2
## z = -2.1535, n = 28, p-value = 0.03128
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -110.0000000 2562.0000000 -0.2910053
summer_sd_sens_825 <- sens.slope(summer_standard_dev_all_825$sd_2)
print(summer_sd_sens_825)
##
## Sen's slope
##
## data: summer_standard_dev_all_825$sd_2
## z = -2.1535, n = 28, p-value = 0.03128
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.058327452 -0.003514684
## sample estimates:
## Sen's slope
## -0.02819625
Winter
winter_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_825 <- winter_standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 5.494857 |
| 1989 | 5.999791 |
| 1990 | 5.251188 |
| 1991 | 5.832490 |
| 1992 | 4.938748 |
| 1993 | 4.494783 |
| 1996 | 5.174580 |
| 2000 | 5.259068 |
| 2001 | 4.039683 |
| 2003 | 4.164930 |
| 2004 | 5.380325 |
| 2005 | 4.316359 |
| 2006 | 5.229662 |
| 2007 | 5.585213 |
| 2009 | 5.156260 |
| 2010 | 5.255018 |
| 2011 | 5.213407 |
| 2012 | 4.931749 |
| 2013 | 5.663046 |
| 2014 | 4.634904 |
| 2015 | 5.233034 |
| 2016 | 4.676311 |
| 2017 | 6.126338 |
| 2018 | 4.516826 |
| 2019 | 4.200310 |
| 2020 | 4.657021 |
| 2021 | 4.783771 |
| 2022 | 5.379918 |
ggplot(winter_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average winter temperatures for water years 2005-2021
winter_sd_mk_825 <- mk.test(winter_standard_dev_all_825$sd_2)
print(winter_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_825$sd_2
## z = -1.0866, n = 28, p-value = 0.2772
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -56.0000000 2562.0000000 -0.1481481
winter_sd_sens_825 <- sens.slope(winter_standard_dev_all_825$sd_2)
print(winter_sd_sens_825)
##
## Sen's slope
##
## data: winter_standard_dev_all_825$sd_2
## z = -1.0866, n = 28, p-value = 0.2772
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04526071 0.01040835
## sample estimates:
## Sen's slope
## -0.01701635
Summer
summer_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_825_ad <- summer_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 2.643642 |
| 1989 | 3.720278 |
| 1990 | 3.203970 |
| 1991 | 2.710620 |
| 1992 | 3.305507 |
| 1993 | 3.433631 |
| 1996 | 2.486762 |
| 2000 | 2.975812 |
| 2001 | 3.347337 |
| 2003 | 4.048348 |
| 2004 | 3.142258 |
| 2005 | 4.165094 |
| 2006 | 2.863342 |
| 2007 | 3.452150 |
| 2009 | 3.648297 |
| 2010 | 3.004765 |
| 2011 | 3.148627 |
| 2012 | 2.515841 |
| 2013 | 2.467608 |
| 2014 | 3.113353 |
| 2015 | 2.574923 |
| 2016 | 2.527747 |
| 2017 | 2.408212 |
| 2018 | 2.739390 |
| 2019 | 3.588753 |
| 2020 | 3.411122 |
| 2021 | 3.070882 |
| 2022 | 3.010445 |
ggplot(summer_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average summer temperatures for water years 1986-2021
summer_sd_mk_825_ad <- mk.test(summer_standard_dev_all_825_ad$sd_2)
print(summer_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_825_ad$sd_2
## z = -0.96807, n = 28, p-value = 0.333
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -50.0000000 2562.0000000 -0.1322751
summer_sd_sens_825_ad <- sens.slope(summer_standard_dev_all_825_ad$sd_2)
print(summer_sd_sens_825_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_825_ad$sd_2
## z = -0.96807, n = 28, p-value = 0.333
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03856893 0.01486051
## sample estimates:
## Sen's slope
## -0.01098489
Winter
winter_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_825_ad <- winter_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 5.377109 |
| 1989 | 5.892200 |
| 1990 | 5.133940 |
| 1991 | 5.753288 |
| 1992 | 4.854132 |
| 1993 | 4.397809 |
| 1996 | 5.074432 |
| 2000 | 5.065285 |
| 2001 | 3.957869 |
| 2003 | 4.069768 |
| 2004 | 5.246595 |
| 2005 | 4.317708 |
| 2006 | 5.229518 |
| 2007 | 5.587273 |
| 2009 | 5.156167 |
| 2010 | 5.255331 |
| 2011 | 5.214178 |
| 2012 | 4.933272 |
| 2013 | 5.664563 |
| 2014 | 4.636241 |
| 2015 | 5.233004 |
| 2016 | 4.676942 |
| 2017 | 6.127398 |
| 2018 | 4.517113 |
| 2019 | 4.200208 |
| 2020 | 4.656905 |
| 2021 | 4.784311 |
| 2022 | 5.380166 |
ggplot(winter_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average winter temperatures for water years 1986-2021
winter_sd_mk_825_ad <- mk.test(winter_standard_dev_all_825_ad$sd_2)
print(winter_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_825_ad$sd_2
## z = -0.61245, n = 28, p-value = 0.5402
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -32.00000000 2562.00000000 -0.08465608
winter_sd_sens_825_ad <- sens.slope(winter_standard_dev_all_825_ad$sd_2)
print(winter_sd_sens_825_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_825_ad$sd_2
## z = -0.61245, n = 28, p-value = 0.5402
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03931264 0.01654364
## sample estimates:
## Sen's slope
## -0.01136106
spring_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_825 <- spring_standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 5.602515 |
| 1989 | 5.174395 |
| 1990 | 3.952392 |
| 1991 | 5.792830 |
| 1992 | 4.160606 |
| 1993 | 5.021151 |
| 1996 | 5.200281 |
| 2000 | 5.307121 |
| 2001 | 4.972500 |
| 2003 | 5.885452 |
| 2004 | 4.517307 |
| 2005 | 4.625389 |
| 2006 | 4.543795 |
| 2007 | 4.944127 |
| 2009 | 4.913259 |
| 2010 | 4.899716 |
| 2011 | 4.060965 |
| 2012 | 4.545771 |
| 2013 | 5.837741 |
| 2014 | 5.610917 |
| 2015 | 3.388918 |
| 2016 | 4.223876 |
| 2017 | 4.786500 |
| 2018 | 5.238785 |
| 2019 | 3.818589 |
| 2020 | 5.490862 |
| 2021 | 4.932690 |
| 2022 | 5.317092 |
ggplot(spring_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average spring temperatures for water years 2005-2021
spring_sd_mk_825 <- mk.test(spring_standard_dev_all_825$sd_2)
print(spring_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_825$sd_2
## z = -0.61245, n = 28, p-value = 0.5402
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -32.00000000 2562.00000000 -0.08465608
spring_sd_sens_825 <- sens.slope(spring_standard_dev_all_825$sd_2)
print(spring_sd_sens_825)
##
## Sen's slope
##
## data: spring_standard_dev_all_825$sd_2
## z = -0.61245, n = 28, p-value = 0.5402
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04923260 0.02596147
## sample estimates:
## Sen's slope
## -0.01206578
Fall
fall_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_825 <- fall_standard_dev_all_825 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.849086 |
| 1989 | 3.691253 |
| 1990 | 6.950698 |
| 1991 | 5.732865 |
| 1992 | 5.964283 |
| 1993 | 4.296375 |
| 1996 | 6.164814 |
| 2000 | 5.240968 |
| 2001 | 5.229732 |
| 2003 | 5.137463 |
| 2004 | 4.658524 |
| 2005 | 4.867919 |
| 2006 | 4.554763 |
| 2007 | 5.869128 |
| 2009 | 5.342090 |
| 2010 | 7.099818 |
| 2011 | 5.012100 |
| 2012 | 5.474515 |
| 2013 | 5.755391 |
| 2014 | 6.126379 |
| 2015 | 4.588082 |
| 2016 | 4.146229 |
| 2017 | 4.947666 |
| 2018 | 5.926442 |
| 2019 | 5.953175 |
| 2020 | 7.653263 |
| 2021 | 6.134202 |
| 2022 | 6.382809 |
ggplot(fall_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_825 <- mk.test(fall_standard_dev_all_825$sd_2)
print(fall_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_825$sd_2
## z = 1.6003, n = 28, p-value = 0.1095
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 82.0000000 2562.0000000 0.2169312
fall_sd_sens_825 <- sens.slope(fall_standard_dev_all_825$sd_2)
print(fall_sd_sens_825)
##
## Sen's slope
##
## data: fall_standard_dev_all_825$sd_2
## z = 1.6003, n = 28, p-value = 0.1095
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01175773 0.08441889
## sample estimates:
## Sen's slope
## 0.0401078
Spring
spring_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_825_ad <- spring_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 5.194265 |
| 1989 | 4.792828 |
| 1990 | 3.663264 |
| 1991 | 5.419904 |
| 1992 | 3.840234 |
| 1993 | 4.664332 |
| 1996 | 4.843487 |
| 2000 | 4.912318 |
| 2001 | 4.606250 |
| 2003 | 5.443424 |
| 2004 | 4.180008 |
| 2005 | 4.625185 |
| 2006 | 4.544503 |
| 2007 | 4.944392 |
| 2009 | 4.913729 |
| 2010 | 4.899393 |
| 2011 | 4.061214 |
| 2012 | 4.546913 |
| 2013 | 5.837979 |
| 2014 | 5.611994 |
| 2015 | 3.389270 |
| 2016 | 4.224413 |
| 2017 | 4.786213 |
| 2018 | 5.238912 |
| 2019 | 3.818750 |
| 2020 | 5.491122 |
| 2021 | 4.932915 |
| 2022 | 5.318028 |
ggplot(spring_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average spring temperatures for water years 1986-2021
spring_sd_mk_825_ad <- mk.test(spring_standard_dev_all_825_ad$sd_2)
print(spring_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_825_ad$sd_2
## z = 0.69148, n = 28, p-value = 0.4893
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.60000e+01 2.56200e+03 9.52381e-02
spring_sd_sens_825_ad <- sens.slope(spring_standard_dev_all_825_ad$sd_2)
print(spring_sd_sens_825_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_825_ad$sd_2
## z = 0.69148, n = 28, p-value = 0.4893
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02249986 0.04217751
## sample estimates:
## Sen's slope
## 0.007390614
Fall
fall_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_825_ad <- fall_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.423610 |
| 1989 | 3.348824 |
| 1990 | 6.403425 |
| 1991 | 5.290809 |
| 1992 | 5.584121 |
| 1993 | 3.948370 |
| 1996 | 5.696964 |
| 2000 | 4.828086 |
| 2001 | 4.778374 |
| 2003 | 4.747575 |
| 2004 | 4.324732 |
| 2005 | 4.870769 |
| 2006 | 4.555210 |
| 2007 | 5.870165 |
| 2009 | 5.340799 |
| 2010 | 7.102839 |
| 2011 | 5.013706 |
| 2012 | 5.478255 |
| 2013 | 5.757397 |
| 2014 | 6.127935 |
| 2015 | 4.590360 |
| 2016 | 4.148193 |
| 2017 | 4.947223 |
| 2018 | 5.928274 |
| 2019 | 5.954735 |
| 2020 | 7.655158 |
| 2021 | 6.134539 |
| 2022 | 6.383507 |
ggplot(fall_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_825_ad <- mk.test(fall_standard_dev_all_825_ad$sd_2)
print(fall_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_825_ad$sd_2
## z = 2.6276, n = 28, p-value = 0.008599
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 134.0000000 2562.0000000 0.3544974
fall_sd_sens_825_ad <- sens.slope(fall_standard_dev_all_825_ad$sd_2)
print(fall_sd_sens_825_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_825_ad$sd_2
## z = 2.6276, n = 28, p-value = 0.008599
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## 0.01432064 0.10414950
## sample estimates:
## Sen's slope
## 0.06181756
Original 12/13/2004
snotel_827 <- SNOTEL_yampa_area %>%
filter(site_id == "827")
#str(snotel_827) # check the date, usually a character.
snotel_827$Date <- as.Date(snotel_827$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_827_clean <- snotel_827 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_827_clean <- snotel_827_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_827_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_827_clean <- snotel_827_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 30)
ggplot(snotel_827_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_827_cull_count <- snotel_827_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_827_cull_count
# filtering for too few observations in a year
snotel_827_cull_count_days <- snotel_827_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_827_cull_count_days
## # A tibble: 18 x 2
## # Groups: waterYear [18]
## waterYear n
## <dbl> <int>
## 1 1986 331
## 2 1994 179
## 3 1995 323
## 4 1996 53
## 5 1997 278
## 6 1999 341
## 7 2001 348
## 8 2002 310
## 9 2003 340
## 10 2004 342
## 11 2009 342
## 12 2010 346
## 13 2011 326
## 14 2013 236
## 15 2014 241
## 16 2016 321
## 17 2017 219
## 18 2019 332
snotel_827_clean_culled <- snotel_827_clean %>%
filter(waterYear != "1986" & waterYear != "1994" & waterYear != "1995" & waterYear != "1996" & waterYear != "1997" & waterYear != "1999" & waterYear != "2001" & waterYear != "2002" & waterYear != "2003" & waterYear != "2004" & waterYear != "2009" & waterYear != "2010" & waterYear != "2011" & waterYear != "2013" & waterYear != "2014" & waterYear != "2016" & waterYear != "2017" & waterYear != "2019") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_827_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_827_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_827_xts <- xts(snotel_827_clean_culled$temperature_mean, order.by = snotel_827_clean_culled$Date)
dygraph(temp_827_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_827_clean_culled <- snotel_827_clean_culled %>%
# filter(temperature_mean > -30)
#temp_827_xts <- xts(snotel_827_clean_culled$temperature_mean, order.by = snotel_827_clean_culled$Date)
#dygraph(temp_827_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
Original 12/13/2004
snotel_827_adjusted <- snotel_827_clean_culled %>%
mutate(temp_ad = if_else(Date < "2004-12-13", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_827 <- snotel_827_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_827 <- yearly_wy_aver_827 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(aver_ann_temp))
#average mean temperature by day for the period of record:
daily_wy_aver_827 <- daily_wy_aver_827 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_827$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_827 <-daily_wy_aver_827 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_827$date_temp <- signif(daily_wy_aver2_827$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_827, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_827 <- daily_wy_aver_827 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_827 <- standard_dev_827 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_827 <- standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.785352 |
| 1988 | 9.643636 |
| 1989 | 9.399426 |
| 1990 | 9.017517 |
| 1991 | 9.053817 |
| 1992 | 8.461780 |
| 1993 | 8.592203 |
| 1998 | 9.226580 |
| 2000 | 8.675610 |
| 2005 | 7.901837 |
| 2006 | 8.811208 |
| 2007 | 8.956871 |
| 2008 | 9.053611 |
| 2012 | 8.641372 |
| 2015 | 7.855779 |
| 2018 | 8.196461 |
| 2020 | 8.933495 |
| 2021 | 8.790312 |
| 2022 | 8.662496 |
ggplot(standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average temperatures for water years 2005-2021
sd_mk_827 <- mk.test(standard_dev_all_827$sd_2)
print(sd_mk_827)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_827$sd_2
## z = -1.7493, n = 19, p-value = 0.08024
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -51.0000000 817.0000000 -0.2982456
sd_sens_827 <- sens.slope(standard_dev_all_827$sd_2)
print(sd_sens_827)
##
## Sen's slope
##
## data: standard_dev_all_827$sd_2
## z = -1.7493, n = 19, p-value = 0.08024
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.06891402 0.00422489
## sample estimates:
## Sen's slope
## -0.03456914
#using the clean culled df:
#average water year temperature
yearly_wy_aver_827_ad <- snotel_827_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_827_ad <- yearly_wy_aver_827_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(aver_ann_temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_827_ad <- daily_wy_aver_827_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_827_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_827_ad <-daily_wy_aver_827_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_827_ad$date_temp_ad <- signif(daily_wy_aver2_827_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_827_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_827_ad <- daily_wy_aver_827_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_827_ad <- standard_dev_827_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_827_ad <- standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 8.205336 |
| 1988 | 9.015708 |
| 1989 | 8.826659 |
| 1990 | 8.399945 |
| 1991 | 8.491804 |
| 1992 | 7.896678 |
| 1993 | 8.029814 |
| 1998 | 8.583994 |
| 2000 | 8.036502 |
| 2005 | 7.717045 |
| 2006 | 8.811366 |
| 2007 | 8.957047 |
| 2008 | 9.053812 |
| 2012 | 8.641373 |
| 2015 | 7.856092 |
| 2018 | 8.196931 |
| 2020 | 8.933512 |
| 2021 | 8.790758 |
| 2022 | 8.663052 |
ggplot(standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average temperatures for water years 1986-2021
sd_mk_827_ad <- mk.test(standard_dev_all_827_ad$sd_2)
print(sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_827_ad$sd_2
## z = 0.41983, n = 19, p-value = 0.6746
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 13.00000000 817.00000000 0.07602339
sd_sens_827_ad <- sens.slope(standard_dev_all_827_ad$sd_2)
print(sd_sens_827_ad)
##
## Sen's slope
##
## data: standard_dev_all_827_ad$sd_2
## z = 0.41983, n = 19, p-value = 0.6746
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03007505 0.05895184
## sample estimates:
## Sen's slope
## 0.012232
Note: figure captions are incorrect.
summer_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_827 <- summer_standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.975403 |
| 1988 | 2.794109 |
| 1989 | 3.852050 |
| 1990 | 3.107783 |
| 1991 | 2.402147 |
| 1992 | 3.427236 |
| 1993 | 3.433262 |
| 1998 | 3.798027 |
| 2000 | 2.676123 |
| 2005 | 3.850483 |
| 2006 | 2.491532 |
| 2007 | 3.111749 |
| 2008 | 3.359290 |
| 2012 | 2.395215 |
| 2015 | 2.435768 |
| 2018 | 2.355727 |
| 2020 | 2.989039 |
| 2021 | 2.789686 |
| 2022 | 2.476165 |
ggplot(summer_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average summer temperatures for water years 2005-2021
summer_sd_mk_827 <- mk.test(summer_standard_dev_all_827$sd_2)
print(summer_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_827$sd_2
## z = -1.6093, n = 19, p-value = 0.1075
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -47.0000000 817.0000000 -0.2748538
summer_sd_sens_827 <- sens.slope(summer_standard_dev_all_827$sd_2)
print(summer_sd_sens_827)
##
## Sen's slope
##
## data: summer_standard_dev_all_827$sd_2
## z = -1.6093, n = 19, p-value = 0.1075
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.08774749 0.01009936
## sample estimates:
## Sen's slope
## -0.03361969
Winter
winter_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_827 <- winter_standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.971678 |
| 1988 | 5.562861 |
| 1989 | 6.720810 |
| 1990 | 5.199356 |
| 1991 | 5.647030 |
| 1992 | 4.595721 |
| 1993 | 4.852622 |
| 1998 | 4.859497 |
| 2000 | 5.169991 |
| 2005 | 3.863484 |
| 2006 | 5.562260 |
| 2007 | 6.079010 |
| 2008 | 5.936987 |
| 2012 | 5.042960 |
| 2015 | 5.329438 |
| 2018 | 4.706908 |
| 2020 | 4.957126 |
| 2021 | 4.705858 |
| 2022 | 5.512016 |
ggplot(winter_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average winter temperatures for water years 2005-2021
winter_sd_mk_827 <- mk.test(winter_standard_dev_all_827$sd_2)
print(winter_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_827$sd_2
## z = -0.69971, n = 19, p-value = 0.4841
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -21.000000 817.000000 -0.122807
winter_sd_sens_827 <- sens.slope(winter_standard_dev_all_827$sd_2)
print(winter_sd_sens_827)
##
## Sen's slope
##
## data: winter_standard_dev_all_827$sd_2
## z = -0.69971, n = 19, p-value = 0.4841
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.07554962 0.03624464
## sample estimates:
## Sen's slope
## -0.01563648
Summer
summer_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_827_ad <- summer_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.669585 |
| 1988 | 2.518259 |
| 1989 | 3.461517 |
| 1990 | 2.791928 |
| 1991 | 2.158069 |
| 1992 | 3.088614 |
| 1993 | 3.095066 |
| 1998 | 3.419196 |
| 2000 | 2.396796 |
| 2005 | 3.850692 |
| 2006 | 2.489776 |
| 2007 | 3.111201 |
| 2008 | 3.357783 |
| 2012 | 2.398136 |
| 2015 | 2.438276 |
| 2018 | 2.354606 |
| 2020 | 2.989403 |
| 2021 | 2.791698 |
| 2022 | 2.475313 |
ggplot(summer_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average summer temperatures for water years 1986-2021
summer_sd_mk_827_ad <- mk.test(summer_standard_dev_all_827_ad$sd_2)
print(summer_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_827_ad$sd_2
## z = -0.62974, n = 19, p-value = 0.5289
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -19.0000000 817.0000000 -0.1111111
summer_sd_sens_827_ad <- sens.slope(summer_standard_dev_all_827_ad$sd_2)
print(summer_sd_sens_827_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_827_ad$sd_2
## z = -0.62974, n = 19, p-value = 0.5289
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05325053 0.04013997
## sample estimates:
## Sen's slope
## -0.01037345
Winter
winter_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_827_ad <- winter_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.832907 |
| 1988 | 5.415501 |
| 1989 | 6.562270 |
| 1990 | 5.034715 |
| 1991 | 5.540803 |
| 1992 | 4.461766 |
| 1993 | 4.726342 |
| 1998 | 4.701690 |
| 2000 | 4.966099 |
| 2005 | 3.903063 |
| 2006 | 5.563646 |
| 2007 | 6.079186 |
| 2008 | 5.936678 |
| 2012 | 5.043322 |
| 2015 | 5.329844 |
| 2018 | 4.708755 |
| 2020 | 4.957166 |
| 2021 | 4.705213 |
| 2022 | 5.513432 |
ggplot(winter_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average winter temperatures for water years 1986-2021
winter_sd_mk_827_ad <- mk.test(winter_standard_dev_all_827_ad$sd_2)
print(winter_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_827_ad$sd_2
## z = -0.20991, n = 19, p-value = 0.8337
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -7.00000000 817.00000000 -0.04093567
winter_sd_sens_827_ad <- sens.slope(winter_standard_dev_all_827_ad$sd_2)
print(winter_sd_sens_827_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_827_ad$sd_2
## z = -0.20991, n = 19, p-value = 0.8337
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.07054102 0.05693862
## sample estimates:
## Sen's slope
## -0.001954077
spring_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_827 <- spring_standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.221083 |
| 1988 | 5.170944 |
| 1989 | 5.194102 |
| 1990 | 3.626141 |
| 1991 | 5.396945 |
| 1992 | 3.825583 |
| 1993 | 4.832296 |
| 1998 | 4.817163 |
| 2000 | 5.439171 |
| 2005 | 4.480210 |
| 2006 | 4.319431 |
| 2007 | 4.412763 |
| 2008 | 5.285845 |
| 2012 | 4.126501 |
| 2015 | 3.031710 |
| 2018 | 5.138064 |
| 2020 | 5.239115 |
| 2021 | 4.530411 |
| 2022 | 5.248168 |
ggplot(spring_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average spring temperatures for water years 2005-2021
spring_sd_mk_827 <- mk.test(spring_standard_dev_all_827$sd_2)
print(spring_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_827$sd_2
## z = 0.27988, n = 19, p-value = 0.7796
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 9.00000000 817.00000000 0.05263158
spring_sd_sens_827 <- sens.slope(spring_standard_dev_all_827$sd_2)
print(spring_sd_sens_827)
##
## Sen's slope
##
## data: spring_standard_dev_all_827$sd_2
## z = 0.27988, n = 19, p-value = 0.7796
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.06772948 0.07559137
## sample estimates:
## Sen's slope
## 0.004544746
Fall
fall_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_827 <- fall_standard_dev_all_827 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.866541 |
| 1988 | 4.054210 |
| 1989 | 3.787036 |
| 1990 | 6.235722 |
| 1991 | 4.395107 |
| 1992 | 5.402001 |
| 1993 | 4.049026 |
| 1998 | 6.247765 |
| 2000 | 5.184618 |
| 2005 | 5.092883 |
| 2006 | 4.176536 |
| 2007 | 5.679568 |
| 2008 | 4.193038 |
| 2012 | 4.707641 |
| 2015 | 3.862253 |
| 2018 | 5.357183 |
| 2020 | 7.732616 |
| 2021 | 5.480414 |
| 2022 | 5.636886 |
ggplot(fall_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_827 <- mk.test(fall_standard_dev_all_827$sd_2)
print(fall_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_827$sd_2
## z = 1.6793, n = 19, p-value = 0.09309
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 49.0000000 817.0000000 0.2865497
fall_sd_sens_827 <- sens.slope(fall_standard_dev_all_827$sd_2)
print(fall_sd_sens_827)
##
## Sen's slope
##
## data: fall_standard_dev_all_827$sd_2
## z = 1.6793, n = 19, p-value = 0.09309
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01476594 0.16475963
## sample estimates:
## Sen's slope
## 0.0647
Spring
spring_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_827_ad <- spring_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.893473 |
| 1988 | 4.769788 |
| 1989 | 4.783557 |
| 1990 | 3.335154 |
| 1991 | 5.004711 |
| 1992 | 3.504389 |
| 1993 | 4.463385 |
| 1998 | 4.432575 |
| 2000 | 4.981388 |
| 2005 | 4.483013 |
| 2006 | 4.320133 |
| 2007 | 4.412238 |
| 2008 | 5.286559 |
| 2012 | 4.128101 |
| 2015 | 3.030691 |
| 2018 | 5.138503 |
| 2020 | 5.237458 |
| 2021 | 4.530231 |
| 2022 | 5.248466 |
ggplot(spring_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average spring temperatures for water years 1986-2021
spring_sd_mk_827_ad <- mk.test(spring_standard_dev_all_827_ad$sd_2)
print(spring_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_827_ad$sd_2
## z = 1.2595, n = 19, p-value = 0.2079
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 37.0000000 817.0000000 0.2163743
spring_sd_sens_827_ad <- sens.slope(spring_standard_dev_all_827_ad$sd_2)
print(spring_sd_sens_827_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_827_ad$sd_2
## z = 1.2595, n = 19, p-value = 0.2079
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03575501 0.08548684
## sample estimates:
## Sen's slope
## 0.03001403
Fall
fall_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_827_ad <- fall_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.538262 |
| 1988 | 3.687673 |
| 1989 | 3.435436 |
| 1990 | 5.753330 |
| 1991 | 4.039246 |
| 1992 | 5.015653 |
| 1993 | 3.714739 |
| 1998 | 5.733649 |
| 2000 | 4.748354 |
| 2005 | 4.476697 |
| 2006 | 4.177413 |
| 2007 | 5.679250 |
| 2008 | 4.194505 |
| 2012 | 4.706209 |
| 2015 | 3.861806 |
| 2018 | 5.356733 |
| 2020 | 7.732635 |
| 2021 | 5.478711 |
| 2022 | 5.636838 |
ggplot(fall_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_827_ad <- mk.test(fall_standard_dev_all_827_ad$sd_2)
print(fall_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_827_ad$sd_2
## z = 2.1691, n = 19, p-value = 0.03007
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 63.0000000 817.0000000 0.3684211
fall_sd_sens_827_ad <- sens.slope(fall_standard_dev_all_827_ad$sd_2)
print(fall_sd_sens_827_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_827_ad$sd_2
## z = 2.1691, n = 19, p-value = 0.03007
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## 0.01339489 0.16036105
## sample estimates:
## Sen's slope
## 0.1042706